This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Syntax to make .altmacro feature %EXPR work?
- From: Erik Christiansen <dvalin at internode dot on dot net>
- To: binutils at sourceware dot org
- Date: Sat, 6 Jan 2018 13:09:17 +1100
- Subject: Syntax to make .altmacro feature %EXPR work?
- Authentication-results: sourceware.org; auth=none
Attempting to generate three symbols, fred0, fred1, fred2, is thwarted
by errors, despite various guesses at legal %EXPR syntax:
.altmacro
.macro foo hoo hah
.equ fred%(\hoo) , \hah
.endm
i = 0
.rept 3
foo i (42+i)
i = i + 1
.endr
gives, three times: Error: expected comma after "fred"
The list file shows: >> .equ fred%(i(42+i)),
Adding a separator: .equ fred%(\hoo)& , \hah
gives a listing of: >> .equ fred%(i(42+i))&,
Maybe %EXPR doesn't support macro parameter expansion? Let's try:
.altmacro
.macro foo n hah
i = 0
.rept \n
.equ fred%(i)& , \hah&+i
i = i + 1
.endr
.endm
foo 3 42
The error message is still:
Error: expected comma after "fred"
and the listing is a much improved: >> .equ fred%(i)&,42+i
But the % operator then appears to be running past the '&' separator, to
swallow all of the rest of the line.
Is there currently a way to elicit the documented behaviour with a
textually bounded expression?:
»
`Expression results as strings'
You can write `%EXPR' to evaluate the expression EXPR and use the
result as a string.
«
The attempts were made both with the latest avr-as version on my recent
debian install: 2.26.20160125, and version 2.28 i686 native gas.
Erik