public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* recursive gas macros and handling characters/strings
@ 2007-10-25  2:30 Mike Frysinger
  2007-10-25  8:30 ` Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Frysinger @ 2007-10-25  2:30 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1307 bytes --]

recently i did some work which required outputting a string in some code which 
could not utilize any other section than the .text nor could use relocations 
(think low level init bootstrap code that is run at power on).  what i came 
up with is something like:
send_string 'm', 'o', 'o', ' ', 'm', 'r', '.', ' ', 'c', 'o', 'w'
and the send_string macro was defined as:
.macro send_string byte:req morebytes:vararg
	R0 = \byte;
	call _push_out_char;
.ifnb \morebytes
	send_string \morebytes
.endif
.endm

from my tests, it looks like the evaluation of arguments happens before the 
expansion of the macro ... in other words, macro expansion isnt quite as 
clean as cpp->c expansion.  what i would have liked to do is:
send_string m, o, o,  , m, r, ....
and then had the macro boil down to:
	R0 = '\()\byte\()';
but this does not seem to work.  am i missing something or is this correct ?

also, i couldnt seem to find a way to parse strings with the gas macro 
language ... so what would have been ideal is:
send_string "moo mr. cow"
and then had the send_string macro actually parcel it up into the individual 
bytes ... but i dont think that's possible to transfer between the data 
representations in gas.

thanks in advance for any random points of enlightenment :)
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: recursive gas macros and handling characters/strings
  2007-10-25  2:30 recursive gas macros and handling characters/strings Mike Frysinger
@ 2007-10-25  8:30 ` Jan Beulich
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2007-10-25  8:30 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: binutils

>>> Mike Frysinger <vapier@gentoo.org> 25.10.07 03:05 >>>
>recently i did some work which required outputting a string in some code which 
>could not utilize any other section than the .text nor could use relocations 
>(think low level init bootstrap code that is run at power on).  what i came 
>up with is something like:
>send_string 'm', 'o', 'o', ' ', 'm', 'r', '.', ' ', 'c', 'o', 'w'
>and the send_string macro was defined as:
>.macro send_string byte:req morebytes:vararg
>R0 = \byte;
>call _push_out_char;
>.ifnb \morebytes
>send_string \morebytes
>.endif
>.endm
>
>from my tests, it looks like the evaluation of arguments happens before the 
>expansion of the macro ... in other words, macro expansion isnt quite as 
>clean as cpp->c expansion.  what i would have liked to do is:
>send_string m, o, o,  , m, r, ....
>and then had the macro boil down to:
>R0 = '\()\byte\()';
>but this does not seem to work.  am i missing something or is this correct ?

It's not the macro parameter expansion that hurts you I assume, but the
quoted character handling (which is done in the scrubber, so the macro
never really gets the quoted character to see.

Jan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-25  7:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-25  2:30 recursive gas macros and handling characters/strings Mike Frysinger
2007-10-25  8:30 ` Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).