summaryrefslogtreecommitdiff
path: root/test/xdefine.asm
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2019-10-23 12:00:50 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2019-10-23 12:00:50 -0700
commit4b58ec1b8f7626517077a70049805878b3dcd50b (patch)
tree73880f2579c512b9488d4988a0b7e9ca226730d4 /test/xdefine.asm
parentf770ce8be48f17b772c3a9c32b3da944e155f502 (diff)
downloadnasm-4b58ec1b8f7626517077a70049805878b3dcd50b.tar.gz
preproc: properly protect %xdefine params (see below), cleanups
1. %xdefine was broken because the code used i as a loop, which is a standard use for the name i. To avoid that confusion in the future, use "op" rather than "i" to hold the directive constant. 2. Once (1) was fixed, the smacro expansion code would fail because of parameter token numbers being indistinguishable between the ongoing expansion and the %xdefine parameters. In a first pass, mark the parameters with a new TOK_XDEF_PARAM token number, and change them to proper parameter token numbers in a second pass, which is now moved into define_smacro() which is where it arguably belongs. 3. Add a few tests for token pasting and xdefine with and without parameters. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Diffstat (limited to 'test/xdefine.asm')
-rw-r--r--test/xdefine.asm11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/xdefine.asm b/test/xdefine.asm
new file mode 100644
index 00000000..3b475864
--- /dev/null
+++ b/test/xdefine.asm
@@ -0,0 +1,11 @@
+%idefine d dword
+%define _1digits_nocheck(d) (((d)% 10)+'0')
+%xdefine _1digits(d) (!!(d/10)*(1<<32)+ _1digits_nocheck(d))
+
+ db _1digits(8) ; Should be 0x38
+
+%define n 0x21
+%xdefine ctr n
+%define n 0x22
+
+ db ctr, n ; Should be 0x21, 0x22