This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: macro behavior


>>> Erik Christiansen <erik@dd.nec.com.au> 15.04.05 04:47:03 >>>
>On Thu, Apr 14, 2005 at 04:42:59PM +0200, Jan Beulich wrote:
>> (1) If I want to append a constant suffix to the expanded string, I
>> see no way to do so in default mode; in .altmacro mode I am able to do
>> so using the & macro operator:
>>
>> 	.macro m sym
>> 	.equiv &sym&_, 1
>> 	.endm
>
>   For me, prepending of constants, and appending of the constant '.' and
>parameter names works fine in gas. (Tested only on avr-as 20030512, so far,
>I'm afraid). For some odd reason, your choice of '_' does break the
>appending mechanism. Here is what works for me:
>
>  .macro struct_elem name, size, elem    ; Declare an element of struct "name"
>  \name.\elem = oneof_\name              ; Generate element offset.
>  oneof_\name = oneof_\name + \size      ; Size of one struct.
>  .endm

Without having tried it out, I'd say this doesn't work anymore in mainline; . previously wasn't considered a character valid for macro arguments, but now macro argument names follow the rules for symbol names (as they always should have), and thus \name.\elem now gets split into "\name." and "\elem" rather than "\name", ".", and "\elem".

>   If a more flexible syntax evolves, that would be nifty, but the
>existing code is in volume production, so is fixing what we have an
>option?  ;-)

Zack's suggestion seems very promising to me, though. I'll look into whether that can be implemented without caveats.

Jan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]