.macro error "constant value required"

View: New views
2 Messages — Rating Filter:   Alert me  

.macro error "constant value required"

by darkschine :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi guys, recently started using avr-gcc for assembly programming and I'm having alot of trouble getting my macro's to work properly.

This is a test file I'm using:
#####################################
.macro testMacro data
  ser data
.endm

.global main
main:

testMacro r16

end: rjmp end
#################################
this is the output:
################################
alex@alex-laptop:~/workspace/3117/project/LCD$ make
avr-gcc -g -mmcu=atmega328p -Wall -Wstrict-prototypes -Os -mcall-prologues -O0 -c lcd.S
lcd.S: Assembler messages:
lcd.S:8: Error: constant value required
lcd.S:8: Error: register number above 15 required
make: *** [lcd.o] Error 1
###################################

I think it's complaining that r16 is not a constant, and since the assignment failed, it complains that "data" is not a register above 15. I understand that the value in r16 isn't a constant, but it's the address of r16 I want to send to the macro. Even when I change r16 to 0x10 I get the same error. The compiler must pick up that 0x10 is the address of r16

can anyone help me with this please?

Re: .macro error "constant value required"

by darkschine :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


darkschine wrote:
I think it's complaining that r16 is not a constant, and since the assignment failed, it complains that "data" is not a register above 15. I understand that the value in r16 isn't a constant, but it's the address of r16 I want to send to the macro. Even when I change r16 to 0x10 I get the same error. The compiler must pick up that 0x10 is the address of r16

can anyone help me with this please?

BAH!!! spent all day looking, but wasn't until I actually asked for help that I found the solution myself!

<code>
.macro testMacro data
  ser \data
.endm

.global main
main:

testMacro r16

end: rjmp end
</code>

note the "\" :D