Closed anrikun closed 2 years ago
hey! the error is on the SWITCH [register.asm:16] inside macro => [register.asm:2] cannot use register A in this context
the macro expansion will do
"switch a"
which is not 'a' ! Then the expression parser trigger that A is a reserved word so it cannot be a variable, a label or an alias
in you case, use directly (it's an example) without switch/case
LD A,{value}
Precisely I wanted to avoid an extra LD A,{value}
when not needed.
Basically I wanted to do:
If {value} is a byte, writeLD A,{value} : OUT (C),A
But if {value} is a register, write OUT (C),{value}
directly
I guess I'll write two separate macros then.
doing what you want could be done by adding a new function "is_register", so the code could be like this
switch is_register('{value}')
case 0 : ld a,{value} : out (c),a : break
case 1 : out (c),{value}
endswitch
Can I add such a function myself or does it have to be built in RASM itself?
i will add the function, it must be hardcoded ;)
Great! Thanks a lot! :smile:
i did the math function but i'm stuck (for now) with the one letter case...
print is_register('Bc') ; no confusion, this is a string
print is_register('f') ; confusion for expression parser, this could be a one char string or a value => but i choose value 1st...
mindblowing ;)
Take your time, Edouard and good luck.
fixed with last commit https://github.com/EdouardBERGE/rasm/commit/221212fb859b9f651d4d6a8a11200df963801894
I'm trying to write a macro that would work no matter passed value is a byte or a register. I've tried this:
But when I do
my_macro a
, I get "cannot use register A in this context". Is what I'm trying to achieve supported? Is there a way to check whether a passed value is a register?