Arakula / A09

A09 6800/6801/6809/6309/68HC11 Assembler
GNU General Public License v2.0
40 stars 8 forks source link

Could use an OPT to specify the filler for "UNUSED" space #6

Closed raybellis closed 4 years ago

raybellis commented 4 years ago

Last "significant" issue, I hope :)

For symmetry with f9dasm, it would be really useful to have an option that specifies what byte is written to a binary for space that is not used. It currently uses 0x00, but many systems use 0xff instead.

Granted this doesn't matter when A09 is being used on its own because I could use the FILL directive, but I'd like to get to the point where I can pass my binary into f9dasm and then pass the unmodified assembly back into A09 and get out the exact same binary.

I have large data blocks that I had tagged as "UNUSED" in my project's .info file, but precisely because they're unused I'm unable to force f9dasm to use an INSERT info line to emit a FILL directive.

The alternative is thousands of lines in the intermediate source reading FCB $ff, $ff, $ff, ... but that would be far from ideal. I cannot currently find any other way to coerce f9dasm and A09 to cooperate.

(I note that semantically f9dasm does "the right thing" with UNUSED data and simply writes out an ORG directive at the start of the next used memory location - it's not having the semantic equivalent in A09 that's stumping me just now. Ironically I can't put the FILL directive at the address corresponding to the end of the unused block because that ORG directive gets emitted first...).

Arakula commented 4 years ago

Makes sense. I'll look into it.

Arakula commented 4 years ago

That's an interesting one, since it has two facettes when creating a binary output file:

  1. the character to be used for RMB pseudo-ops (currently fixed to $00)
  2. the character to be used if there's simply an ORG *+something in the code (currently, A09 relies simply on fseek() to position on the new address in the output file) Might take a day or two.
Arakula commented 4 years ago

OK, here's a little test version for you. This one adds a builtin constant called FILCHR, which defaults to $00. FILCHR is used in all empty areas in binary files that result from RMB or ORG.

You can set it either from the command line by adding something like -dFILCHR=$FF to A09's invocation, or inside the assembler source by writing it as FILCHR TEXT $FF or whatever - the value can be anything that fits inside a byte, given in decimal, hexadecimal ($xx), octal (@xx), binary (%xx), or character ('x) notation.

In principle, you can use the constant anywhere, like, for example, in FILL &FILCHR,10 and you can also change it multiple times throughout the source code; if you do so, it is VERY advisable to have a definition at the start of the assembler source file, as it's not reset between the assembler passes.

Please tell me whether this works for you.

Arakula commented 4 years ago

Ironically I can't put the FILL directive at the address corresponding to the end of the unused block because that ORG directive gets emitted first...).

dasmfw, my more modern, but not yet as stable, take on disassemblers, can do things like that, as it has an expanded syntax for COMMENT, INSERT etc. - you can define something like insert after 1234 \ FILL $FF,10 for the last valid address before an UNUSED area. This would be output before the ORGdirective.

raybellis commented 4 years ago

That's working perfectly, thank you! (and thanks for the quick response too).