Copyright (C) 2000-2012 |
GNU Info (nasm.info)Section 4.1.34.1.3. Concatenating Single Line Macro Tokens: `%+' --------------------------------------------------- Individual tokens in single line macros can be concatenated, to produce longer tokens for later processing. This can be useful if there are several similar macros that perform similar functions. As an example, consider the following: %define BDASTART 400h ; Start of BIOS data area struc tBIOSDA ; its structure .COM1addr RESW 1 .COM2addr RESW 1 ; ..and so on endstruc Now, if we need to access the elements of tBIOSDA in different places, we can end up with: mov ax,BDASTART + tBIOSDA.COM1addr mov bx,BDASTART + tBIOSDA.COM2addr This will become pretty ugly (and tedious) if used in many places, and can be reduced in size significantly by using the following macro: ; Macro to access BIOS variables by their names (from tBDA): %define BDA(x) BDASTART + tBIOSDA. %+ x Now the above code can be written as: mov ax,BDA(COM1addr) mov bx,BDA(COM2addr) Using this feature, we can simplify references to a lot of macros (and, in turn, reduce typing errors). automatically generated by info2www version 1.2.2.9 |