-
Notifications
You must be signed in to change notification settings - Fork 477
Description
Is your feature request related to a problem? Please describe.
I've found that when using the ".charmap" directive in ca65 that it will only accept an assemble-time constant as the encoded character value. When trying to use any value that evaluates to a constant at link-time instead, the assembler balks at allowing this saying that a constant expression is expected. Problem is, this is a constant value, it does not change in-situ during execution, the value is simply edited in by the linker rather than assembling directly.
Describe the solution you'd like
Instead, like any other entry of a byte value, when interpreting a string against a charmap without assemble-time constants, the result should be treated like any other unresolved reference and filled in at link-time. This allows strings to be built dynamically from the real positions of their resulting character data in some sort of graphical array rather than having to manually edit such collections when the physical position of data moves around.
In other words, it is my belief that
.charmap "T", <link_const_a
.charmap "E", <link_const_b
.charmap "S", <link_const_c
.byte "TEST"
Should be equivalent to
.byte <link_const_a
.byte <link_const_b
.byte <link_const_c
.byte <link_const_a
But the latter would be assembled and linked, the former would not, even though it expresses the exact same thing. My specific use case is I'm working on a disassembly for the NES and I've created a file mapping each PPU character tile to its integer index. These indices for letter tiles then are the encoded value of the character, meaning the value of each character in a string is whatever the linker computes the index of the character to be.
If I build a series of ".byte" directives, each with the address equation for that particular tile, it works just fine, if I move tiles around, the final product still works because each such address is ultimatley filled in by the linker. If I do the exact same thing but with ".charmap" involved to "pretty print" the strings, it all falls apart, requiring me to have assemble-time constant indices for characters even though the value is technically constant, just at link-time.
Please let me know if any further information is needed or if I need to provide a repro, thank you!