Defining macros with parameters XA can be quite tricky. Let me share with you how I solved it.
Particularly I am trying to define a macro for multiplying the contets of regs A and Y and store the 16-bit result in a temporary variable (low) and reg A (high). Something like:
Code: Select all
#define MULTAY(par) sta MultLo1 :\
sta MultHi1 :\
eor #$ff :\
clc :\
adc #1 :\
sta MultLo2 :\
sta MultHi2 :\
sec :\
lda (MultLo1),y :\
sbc (MultLo2),y :\
sta par :\
lda (MultHi1),y :\
sbc (MultHi2),y
This happens even if I do not use the macro... just keep it defined. I have tried everyting I imagined (surely everything *but* the correct option), but still had the problem.
In fact something like #define mult(o1,o2) (o1*o2) does work (at least defining it does not give any error) so I supposed that it was related to the multiple line thing and the fact that the parameter is used inside asm code...
Well. To solve this issue, it is enough to keep the definition in one line, such as:
Code: Select all
#define MULTAY(par) sta MultLo1 : sta MultHi1 : ... : sta par: ...
So we can have quick asm inlined code in an easy way at last!
Cheers.