GAS - \@ in macros and labels
I'm having a little trouble with specifying labels inside of two different macros using the \@ variable. See the following...
.MACRO tableHdr someArgs
A_\@:
.DC.W (B_\@ - A_\@)
stuff.....ENDM
.MACRO tableEnd someArgs
B_\@:
.ENDM
Unfortunately the number produced by \@ will never be in sync between the two macros due to the fact that a new macro call will increment the counter (not to mention that there may be some other macros called in between Hdr and End).
So I attempted to resolve the situation by creating my own variable...
.MACRO tableHdr someArgs
.SET CMD_NUM,\@A_CMD_NUM:
.DC.W (B_CMD_NUM - A_CMD_NUM)
stuff.....ENDM
.MACRO tableEnd someArgsB_CMD_NUM:
.ENDM
Unfortunately GAS sees this as literal text and throws a bunch of "symbol already defined" errors. Any ideas on how to make the CMD_NUM appear as its value in a label? Thanks,
Brian
**********************************************************************
This e-mail and any files transmitted with it are confidential and may be legally privileged or otherwise exempt from disclosure under applicable law. This e-mail and its files are intended solely for the individual or entity to whom they are addressed and their content is the property of Smiths Aerospace. If you are not the intended recipient, please do not read, copy, use or disclose this communication. If you have received this e-mail in error please notify the e-mail administrator at [email protected] and then delete this e-mail, its files and any copies.
This footnote also confirms that this e-mail message has been scanned for the presence of known computer viruses.
***********************************************************************
Quoted 8 lines · On Wed, 29 May 2002 [email protected] wrote:
.MACRO tableHdr someArgs
.SET CMD_NUM,\@A_CMD_NUM:.DC.W (B_CMD_NUM - A_CMD_NUM) stuff.....ENDM
Quoted 8 lines
.MACRO tableEnd someArgs
B_CMD_NUM:
.ENDMUnfortunately GAS sees this as literal text and throws a bunch of "symbol already defined" errors. Any ideas on how to make the
CMD_NUMappear as its value in a label? Thanks,
Please tell me if you figure it out. :)
In the meantime, I use cpp. Then you can use the concatenation operator '##', like
#define tableHdr(cmd_num) A_ ## cmd_num:\
and so on..
Quoted 9 lines · On Thu, 30 May 2002 13:13:25 -0400 Scott Lanning <[email protected]> wrote:
Quoted 8 lines · On Wed, 29 May 2002 [email protected] wrote:
.MACRO tableHdr someArgs
.SET CMD_NUM,\@A_CMD_NUM:.DC.W (B_CMD_NUM - A_CMD_NUM) stuff.....ENDM
Quoted 8 lines
Quoted 8 lines
.MACRO tableEnd someArgs
B_CMD_NUM:
.ENDMUnfortunately GAS sees this as literal text and throws a bunch of "symbol already defined" errors. Any ideas on how to make the
CMD_NUMappear as its value in a label? Thanks,
if you want to generate linked/chained lists, you could use 'local' (numeric) labels, the range of which is far beyond the documented max. of 9. examples can be found in the linux kernel (arch/i386/lib/checksum.S, macroes SRC, DST) or, as aplied in "eForth" (http://www.lxhp.in-berlin.de/index-lx.shtml#e4)
regards,
hp
Signature · 6 lines
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de NO abusive software patents http://petition.eurolinux.org/pr/pr17.html - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html