[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gas: additional macro functionality (patch attached)
From: |
Olaf Püschel |
Subject: |
gas: additional macro functionality (patch attached) |
Date: |
Mon, 13 Aug 2007 16:49:46 +0200 |
Hi!
When I was trying to implement a direct threaded code interpreter
(forth look alike)
with gas for the msp430 microcontroller, I missed the possibility to
reference
a) the individual invocation count of each macro and b) the previous
invocation
count for each macro.
Problem: I need to build a single linked list at assemble time. This
is traditionally
done with somethink like:
.set LINK, 0
.macro HEAD foo, bar
...
.word LINK
.set LINK,.
.endm
This does not work with gas assembling msp430 code on a PPC Mac, because
LINK only gets resoved at relocation time, so all LINK fields are the
same :-(
The presence of the \@ ideom hinted to me, that I could easily tweak
gas to yield
the information I need. So I made two changes::
1) "macro_entry" gets another field "count", giving the individual
invocation count
2) The ideoms \#, \< and \> yield the current, previous amd next
invocation count
when used in a macro.
So I can write the linked list code like:
.macro HEAD len,name,link,flags=0
lnk\#: .byte (\flags << 5) | \len
nam\@: .ascii "\name"
.org nam\@ + 3 ; pad short
names
.word lnk\<
.endm
Tested, works :-)
I would love to see my code incorporated in the next gas release,
since I consider
it useful not only to me. If you need to have some documentation
writen to do this,
i'll be happy to provide it.
Attached are the diff's for macro.h and macro.c
Best regards
Olaf
--
/~\ The ASCII | Olaf P?schel, OLMOS Technologies GmbH, Germany
\ / Ribbon Campaign | Senefelderstra?e 11, 38124 Braunschweig
X Against HTML | Phone: +49-531-22020-0 Fax: +49-531-22020-99
/ \ Email! | OLMOS supports signed and/or encrypted mail.
gas-2.17_macro.c.diff
Description: Binary data
gas-2.17_macro.h.diff
Description: Binary data
- gas: additional macro functionality (patch attached),
Olaf Püschel <=