Hi all,
I'm tearing my hair out trying to figure out how to do something with
ASxxxx assembler macros which ostensibly seems so damn simple, yet I am
having no success figuring out anything that works.
All I want to do is have a macro that will repeat a block of assembly
code a number of times, where that number is given by an argument to the
macro, and have the current iteration value substituted into the code.
The .rept directive is not 100% suitable, as it does not provide the
iteration value within the repeated block. So I thought maybe something
like this:
.macro foo n
addw x, (n, sp)
ldw (n, sp), x
n = n - 2
.rept \n
ld a, #0
adc a, (n, sp)
ld (n, sp), a
n = n - 1
.endm
.endm
But this doesn't work. I just get a "<q> missing or improper operators,
terminators, or delimiters" error, which isn't very helpful, especially
because the line number given is only that where the macro is called.
When called with, for example "foo 6", the resulting assembled code I'm
looking for would be the equivalent of:
addw x, (6, sp)
ldw (6, sp), x
ld a, #0
adc a, (4, sp)
ld (4, sp), a
; ...etc...
ld a, #0
adc a, (0, sp)
ld (0, sp), a
Anyone know how to do this?
Regards,
Basil Hussain
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user