I would like to convert an assembly program in ca65 with macros into assembly code with resolved macros in order to carry out manual or automatic optimizations with the resulting code. Then, the program should be assembled into object code/executable code.
Is there an option or macro for ca65 to make it run only the macro pre-processor?
I'm assembling with
ca65 myprog.s
cl65 myprog.o -C c64-asm.cfg -u __EXEHDR__ -o myprog.prg
or using cl65 in one step
cl65 myprog.s -C c64-asm.cfg -u __EXEHDR__ -o myprog.prg
Mini example for myprog.s with macros:
loop: inc $D021
.repeat 20
nop
.endrep
jmp loop
.repeat
, but I also might have recursive macros and usage of.if
,.ident', ̀set
, etc. Parsing this would mean a reimplementation of the macro processor.ca65 --listing myprog-lst.txt myprog.s
but the listing does not expand the macros to source code either. It shows the program bytes, but on the right just the macro name. It does not add labels generated by the macro for example, a BNE appears just as 06 in the text. Decoding the program bytes would be thus the same as running a disassembler over the generated binary, which is risky since the disassembler could potentially oversee a jump label or misinterpret code. In contrast, the assembler, getting the code from the macro'd sourcecode has this information.