vhelin / wla-dx

WLA DX - Yet Another GB-Z80/Z80/Z80N/6502/65C02/65CE02/65816/68000/6800/6801/6809/8008/8080/HUC6280/SPC-700/SuperFX Multi Platform Cross Assembler Package
Other
549 stars 98 forks source link

macros lack a pure literal parameter type #643

Open sircodalotkob opened 6 hours ago

sircodalotkob commented 6 hours ago

Sometimes, it could be handy to have pure literal parameters in a macro that don't get evaluated or resolved at all.

Consider this macro which performs a complex calculation and then stores the result:

  .macro add_and_store
  move.w #(\1+\2),\3
  .endm

We can call it to store the result in a provided memory location:

  add_and_store 1,2,$00123456
  add_and_store 1,2,myvariable

However, we cannot call it to store the result in a register:

  add_and_store 1,2,d0
  add_and_store 1,2,(a6)
  add_and_store 1,2,(a6)+
  add_and_store 1,2,5(a3)

wla-dx tries to evaluate or resolve the given parameters and consequently gives us FIX_REFERENCES: Reference to an unknown label "d0". for the first example. Currently, there doesn't seem to be a way to have a wla-dx macro just output literals.

sircodalotkob commented 5 hours ago

The simple problem described above can be solved using a wla-dx function instead of a macro. But unlike macros, functions cannot be used to generate code.

vhelin commented 5 hours ago

I'm afraid that the instruction parsers per architecture parse registers 1:1 directly from the source code without any room for aliases/substitutions. There might be a possibility for a workaround/hack here, but not sure. Probably not a simple and quick thing to fix...

Also I think you are the 1st person here who has posted anything related to the 68000 support in WLA DX - I hope it works :)