]> granicus.if.org Git - yasm/commitdiff
Fix #69 by making the NASM preproc and parser use the yasm built-in
authorPeter Johnson <peter@tortall.net>
Fri, 24 Feb 2006 04:29:39 +0000 (04:29 -0000)
committerPeter Johnson <peter@tortall.net>
Fri, 24 Feb 2006 04:29:39 +0000 (04:29 -0000)
alignment bytecode rather than just times'ing a NOP.  This generates better
NOP code.

The new align only triggers when the NASM align directive is used unadorned
or with nop as the parameter (e.g. "align 16" or "align 16, nop").  Other
uses, including all uses of balign, maintain their old NASM behavior.  This
is somewhat useful if you still want a string of NOPs rather than more
optimized instruction patterns: just use "balign X, nop" rather than
"align X".  The new align also follows the GAS behavior of increasing the
section's alignment to be the specified alignment (if not already larger).

While I was in here, I found and fixed a bug in 16-bit alignment generation
(typo).  I also changed the x86 32-bit code alignment fill pattern per
suggestions in the AMD x86 code optimization manual.

* nasm-bison.y: Implement a new [align] directive that can take a single
parameter (the alignment) and generate a nop-generating align bytecode.
* standard.mac: Change align macro to generate [align] if the second
macro parameter is nonexistent or "nop".
* x86arch.c (x86_get_fill): Update 32-bit fill pattern and fix bug in 16-bit
fill pattern.

svn path=/trunk/yasm/; revision=1389

13 files changed:
modules/arch/x86/tests/gas32/align32.hex
modules/arch/x86/x86arch.c
modules/objfmts/coff/tests/x86id.hex
modules/objfmts/elf/tests/elf-x86id.hex
modules/parsers/nasm/nasm-bison.y
modules/parsers/nasm/tests/Makefile.inc
modules/parsers/nasm/tests/alignnop16.asm [new file with mode: 0644]
modules/parsers/nasm/tests/alignnop16.errwarn [new file with mode: 0644]
modules/parsers/nasm/tests/alignnop16.hex [new file with mode: 0644]
modules/parsers/nasm/tests/alignnop32.asm [new file with mode: 0644]
modules/parsers/nasm/tests/alignnop32.errwarn [new file with mode: 0644]
modules/parsers/nasm/tests/alignnop32.hex [new file with mode: 0644]
modules/preprocs/nasm/standard.mac

index 66b48bb960c420536b01288da623fbf0c55787cf..7718196985583616223e3800a2f0834c622bcbec 100644 (file)
@@ -80,84 +80,84 @@ eb
 90 
 ff 
 ff 
-8d 
-b4 
-26 
-0
-0
-0
-0
-8d 
-bc 
-27 
-0
-0
-0
-0
+eb 
+0c 
+90 
+9
+9
+9
+9
+90 
+90 
+90 
+9
+9
+9
+9
 ff 
 ff 
 ff 
-8d 
-b6 
-0
-0
-0
-0
-8d 
-bc 
-27 
-0
-0
-0
-0
+eb 
+0b 
+9
+9
+9
+9
+90 
+90 
+90 
+9
+9
+9
+9
 ff 
 ff 
 ff 
 ff 
-8d 
-b6 
-0
-0
-0
-0
-8d 
-bf 
-0
-0
-0
-0
+eb 
+0a 
+9
+9
+9
+9
+90 
+90 
+9
+9
+9
+9
 ff 
 ff 
 ff 
 ff 
 ff 
-8d 
-74 
-26 
-0
-8d 
-bc 
-27 
-0
-0
-0
-0
+eb 
+09 
+90 
+9
+90 
+90 
+90 
+9
+9
+9
+9
 ff 
 ff 
 ff 
 ff 
 ff 
 ff 
-8d 
-76 
-0
-8d 
-bc 
-27 
-0
-0
-0
-0
+eb 
+08 
+9
+90 
+90 
+90 
+9
+9
+9
+9
 ff 
 ff 
 ff 
@@ -165,15 +165,15 @@ ff
 ff 
 ff 
 ff 
-89 
-f6 
-8d 
-bc 
-27 
-0
-0
-0
-0
+eb 
+07 
+90 
+90 
+90 
+9
+9
+9
+9
 ff 
 ff 
 ff 
index 02be78e1a4f7c7e1cf65b58acca2b1a2fad88f0f..825709b2349a6e4e8034563b25551559d52f46ce 100644 (file)
@@ -159,7 +159,7 @@ x86_get_fill(const yasm_arch *arch)
        "\x8d\x74\x00"                  /* 7 - lea si, [si+byte 0]      */
        "\x8d\xbd\x00\x00",             /*     lea di, [di+word 0]      */
        "\x8d\xb4\x00\x00"              /* 8 - lea si, [si+word 0]      */
-       "\x8d\xbd\x00\x00"              /*     lea di, [di+word 0]      */
+       "\x8d\xbd\x00\x00",             /*     lea di, [di+word 0]      */
        "\xeb\x07\x90\x90\x90\x90\x90"  /* 9 - jmp $+9; nop fill        */
        "\x90\x90",
        "\xeb\x08\x90\x90\x90\x90\x90"  /* 10 - jmp $+10; nop fill      */
@@ -187,6 +187,8 @@ x86_get_fill(const yasm_arch *arch)
        "\x8d\xb4\x26\x00\x00\x00\x00", /* 7 - lea esi, [esi*1+dword 0] */
        "\x90"                          /* 8 - nop                      */
        "\x8d\xb4\x26\x00\x00\x00\x00", /*     lea esi, [esi*1+dword 0] */
+#if 0
+       /* GAS uses these */
        "\x89\xf6"                      /* 9 - mov esi, esi             */
        "\x8d\xbc\x27\x00\x00\x00\x00", /*     lea edi, [edi*1+dword 0] */
        "\x8d\x76\x00"                  /* 10 - lea esi, [esi+byte 0]   */
@@ -199,6 +201,21 @@ x86_get_fill(const yasm_arch *arch)
        "\x8d\xbc\x27\x00\x00\x00\x00", /*      lea edi, [edi*1+dword 0]*/
        "\x8d\xb4\x26\x00\x00\x00\x00"  /* 14 - lea esi, [esi*1+dword 0]*/
        "\x8d\xbc\x27\x00\x00\x00\x00", /*      lea edi, [edi*1+dword 0]*/
+#else
+       /* But on newer processors, these are recommended */
+       "\xeb\x07\x90\x90\x90\x90\x90"  /* 9 - jmp $+9; nop fill        */
+       "\x90\x90",
+       "\xeb\x08\x90\x90\x90\x90\x90"  /* 10 - jmp $+10; nop fill      */
+       "\x90\x90\x90",
+       "\xeb\x09\x90\x90\x90\x90\x90"  /* 11 - jmp $+11; nop fill      */
+       "\x90\x90\x90\x90",
+       "\xeb\x0a\x90\x90\x90\x90\x90"  /* 12 - jmp $+12; nop fill      */
+       "\x90\x90\x90\x90\x90",
+       "\xeb\x0b\x90\x90\x90\x90\x90"  /* 13 - jmp $+13; nop fill      */
+       "\x90\x90\x90\x90\x90\x90",
+       "\xeb\x0c\x90\x90\x90\x90\x90"  /* 14 - jmp $+14; nop fill      */
+       "\x90\x90\x90\x90\x90\x90\x90",
+#endif
        "\xeb\x0d\x90\x90\x90\x90\x90"  /* 15 - jmp $+15; nop fill      */
        "\x90\x90\x90\x90\x90\x90\x90\x90"
     };
index 5f1ed61fde6e8b28e442ac37bfc4320b886b7de9..7339666aa4840945043d9eebddc1a52c1e74c037 100644 (file)
@@ -96,7 +96,7 @@ f2
 00 
 40 
 00 
-0
+3
 00 
 2e 
 72 
@@ -136,7 +136,7 @@ da
 00 
 20 
 00 
-0
+6
 00 
 55 
 89 
@@ -70630,6 +70630,8 @@ ff
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -71914,6 +71914,8 @@ c7
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 04 
 00 
 00 
@@ -72102,6 +72102,8 @@ c7
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -72910,8 +72910,8 @@ a8
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -73514,6 +73514,8 @@ a9
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 00 
 00 
 00 
@@ -73926,6 +73926,8 @@ a9
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -74118,6 +74118,8 @@ ed
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -74310,6 +74310,8 @@ ef
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -74418,8 +74418,8 @@ ef
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 04 
 00 
 00 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 00 
 00 
@@ -75202,6 +75202,8 @@ ef
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+0b 
 90 
 90 
 90 
@@ -75398,6 +75398,8 @@ ff
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -75534,8 +75534,8 @@ f7
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -76110,8 +76110,8 @@ f7
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 00 
 00 
@@ -76722,8 +76722,8 @@ af
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -77126,6 +77126,8 @@ d1
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -77710,8 +77710,8 @@ ff
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -78314,6 +78314,8 @@ ff
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 00 
 00 
 00 
@@ -78418,8 +78418,8 @@ c8
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -78626,6 +78626,8 @@ c8
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+0b 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 00 
 00 
 00 
 00 
 00 
-90 
-90 
-90 
-9
+8d 
+74 
+26 
+0
 04 
 00 
 00 
@@ -79142,6 +79142,8 @@ ba
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -79278,8 +79278,8 @@ cd
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -79378,8 +79378,8 @@ cd
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -79530,6 +79530,8 @@ cd
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 02 
 00 
 00 
@@ -79718,6 +79718,8 @@ cd
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -79854,8 +79854,8 @@ a1
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -79982,8 +79982,8 @@ a2
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -80082,8 +80082,8 @@ a1
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -80206,8 +80206,8 @@ c9
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -80334,8 +80334,8 @@ a1
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 10 
 00 
@@ -80582,6 +80582,8 @@ aa
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -80690,8 +80690,8 @@ aa
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -80814,8 +80814,8 @@ d9
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 10 
 00 
@@ -80978,8 +80978,8 @@ a1
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 08 
 00 
 00 
@@ -81194,6 +81194,8 @@ c7
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 20 
 00 
 00 
@@ -81326,8 +81326,8 @@ a1
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -81426,8 +81426,8 @@ ae
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -81802,6 +81802,8 @@ c4
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 00 
 20 
 00 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 20 
 00 
@@ -82222,8 +82222,8 @@ f7
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -82322,8 +82322,8 @@ c4
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -82474,6 +82474,8 @@ c4
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 00 
 40 
 00 
@@ -82578,8 +82578,8 @@ c4
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 40 
 20 
 00 
@@ -82766,8 +82766,8 @@ c4
 21 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -82866,8 +82866,8 @@ c4
 21 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 80 
 00 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 80 
 00 
@@ -83118,8 +83118,8 @@ c4
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -83274,6 +83274,8 @@ c4
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 00 
 80 
 00 
@@ -83602,8 +83602,8 @@ a2
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 04 
 00 
 20 
@@ -83846,6 +83846,8 @@ a7
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
 00 
 24 
 00 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 00 
 00 
@@ -84133,6 +84133,8 @@ a6
 65 
 64 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+08 
 90 
 90 
 90 
@@ -84225,6 +84225,8 @@ a6
 65 
 72 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+0c 
 90 
 90 
 90 
@@ -84320,6 +84320,8 @@ a6
 6f 
 6e 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -84383,9 +84383,9 @@ a6
 6f 
 6e 
 00 
-90 
-90 
-9
+8d 
+76 
+0
 af 
 03 
 00 
 06 
 00 
 00 
-90 
-90 
-90 
-9
+8d 
+74 
+26 
+0
 75 
 6e 
 72 
@@ -85258,6 +85258,8 @@ fc
 15 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 60 
 73 
 27 
@@ -85322,6 +85322,8 @@ fc
 64 
 65 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 43 
 61 
 6e 
@@ -85397,8 +85397,8 @@ fc
 64 
 65 
 00 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -85471,6 +85471,8 @@ fc
 64 
 65 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
index 1a61d6ed9d3706b30739f2cd061ad78ca50d4f7e..5f3bb4c1f525fade5cabc45c8963e43479171c1a 100644 (file)
 00 
 00 
 00 
+00 
+00 
+00 
+00 
 02 
 00 
 00 
@@ -68930,6 +68934,8 @@ ff
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -70214,6 +70218,8 @@ c7
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 04 
 00 
 00 
@@ -70402,6 +70406,8 @@ c7
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -71210,8 +71214,8 @@ a8
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -71814,6 +71818,8 @@ a9
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 00 
 00 
 00 
@@ -72226,6 +72230,8 @@ a9
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -72418,6 +72422,8 @@ ed
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -72610,6 +72614,8 @@ ef
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -72718,8 +72722,8 @@ ef
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 04 
 00 
 00 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 00 
 00 
@@ -73502,6 +73506,8 @@ ef
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+0b 
 90 
 90 
 90 
@@ -73698,6 +73702,8 @@ ff
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -73834,8 +73838,8 @@ f7
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -74410,8 +74414,8 @@ f7
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 00 
 00 
@@ -75022,8 +75026,8 @@ af
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -75426,6 +75430,8 @@ d1
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -76010,8 +76014,8 @@ ff
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -76614,6 +76618,8 @@ ff
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 00 
 00 
 00 
@@ -76718,8 +76722,8 @@ c8
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -76926,6 +76930,8 @@ c8
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+0b 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 00 
 00 
 00 
 00 
 00 
-90 
-90 
-90 
-9
+8d 
+74 
+26 
+0
 04 
 00 
 00 
@@ -77442,6 +77446,8 @@ ba
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -77578,8 +77582,8 @@ cd
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -77678,8 +77682,8 @@ cd
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -77830,6 +77834,8 @@ cd
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 02 
 00 
 00 
@@ -78018,6 +78022,8 @@ cd
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -78154,8 +78158,8 @@ a1
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -78282,8 +78286,8 @@ a2
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -78382,8 +78386,8 @@ a1
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -78506,8 +78510,8 @@ c9
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -78634,8 +78638,8 @@ a1
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 10 
 00 
@@ -78882,6 +78886,8 @@ aa
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -78990,8 +78994,8 @@ aa
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -79114,8 +79118,8 @@ d9
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 10 
 00 
@@ -79278,8 +79282,8 @@ a1
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 08 
 00 
 00 
@@ -79494,6 +79498,8 @@ c7
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 20 
 00 
 00 
@@ -79626,8 +79630,8 @@ a1
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -79726,8 +79730,8 @@ ae
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -80102,6 +80106,8 @@ c4
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 00 
 20 
 00 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 20 
 00 
@@ -80522,8 +80526,8 @@ f7
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -80622,8 +80626,8 @@ c4
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
@@ -80774,6 +80778,8 @@ c4
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 00 
 40 
 00 
@@ -80878,8 +80882,8 @@ c4
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 40 
 20 
 00 
@@ -81066,8 +81070,8 @@ c4
 21 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -81166,8 +81170,8 @@ c4
 21 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 80 
 00 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 80 
 00 
@@ -81418,8 +81422,8 @@ c4
 00 
 00 
 00 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -81574,6 +81578,8 @@ c4
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 00 
 80 
 00 
@@ -81902,8 +81906,8 @@ a2
 00 
 00 
 00 
-90 
-90 
+eb 
+0a 
 90 
 90 
 90 
 00 
 00 
 90 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 04 
 00 
 20 
@@ -82146,6 +82150,8 @@ a7
 00 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
 00 
 24 
 00 
-90 
-90 
-90 
-9
-9
-9
-9
+8d 
+b4 
+26 
+0
+0
+0
+0
 00 
 00 
 00 
@@ -82433,6 +82437,8 @@ a6
 65 
 64 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+08 
 90 
 90 
 90 
@@ -82525,6 +82529,8 @@ a6
 65 
 72 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+0c 
 90 
 90 
 90 
@@ -82620,6 +82624,8 @@ a6
 6f 
 6e 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
@@ -82683,9 +82687,9 @@ a6
 6f 
 6e 
 00 
-90 
-90 
-9
+8d 
+76 
+0
 af 
 03 
 00 
 06 
 00 
 00 
-90 
-90 
-90 
-9
+8d 
+74 
+26 
+0
 75 
 6e 
 72 
@@ -83558,6 +83562,8 @@ fc
 15 
 00 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 60 
 73 
 27 
@@ -83622,6 +83626,8 @@ fc
 64 
 65 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
-90 
-90 
+8d 
+74 
+26 
+00 
 43 
 61 
 6e 
@@ -83697,8 +83701,8 @@ fc
 64 
 65 
 00 
-90 
-90 
+eb 
+07 
 90 
 90 
 90 
@@ -83771,6 +83775,8 @@ fc
 64 
 65 
 00 
+eb 
+0d 
 90 
 90 
 90 
 90 
 90 
 90 
-90 
-90 
-90 
-90 
+eb 
+0d 
 90 
 90 
 90 
 00 
 00 
 00 
-00 
-00 
-00 
-00 
 3b 
 00 
 00 
 00 
 00 
 00 
-90 
+94 
 a2 
 01 
 00 
 00 
 00 
 00 
-d8 
+dc 
 a2 
 01 
 00 
 00 
 00 
 00 
-bc 
+c0 
 a4 
 01 
 00 
 00 
 00 
 00 
-9c 
+a0 
 0c 
 01 
 00 
 00 
 00 
 00 
-04 
+20 
 00 
 00 
 00 
 00 
 00 
 00 
-c0 
+c4 
 63 
 01 
 00 
index 853f68c88fc279c1e0be552e47a078c815c02551..a56bc6587c6049ff74b884a39ed5afadefdfb439 100644 (file)
@@ -596,6 +596,45 @@ nasm_parser_directive(yasm_parser_nasm *parser_nasm, const char *name,
            vp->param = NULL;
        }
        parser_nasm->prev_bc = yasm_section_bcs_last(parser_nasm->cur_section);
+    } else if (yasm__strcasecmp(name, "align") == 0) {
+       /*@only@*/ yasm_expr *boundval;
+       /*@depedent@*/ yasm_intnum *boundintn;
+
+       /* it can be just an ID or a complete expression, so handle both. */
+       vp = yasm_vps_first(valparams);
+       if (vp->val)
+           boundval = p_expr_new_ident(yasm_expr_sym(
+               yasm_symtab_use(p_symtab, vp->val, line)));
+       else if (vp->param) {
+           boundval = vp->param;
+           vp->param = NULL;
+       }
+
+       /* Largest .align in the section specifies section alignment.
+        * Note: this doesn't match NASM behavior, but is a lot more
+        * intelligent!
+        */
+       boundintn = yasm_expr_get_intnum(&boundval, NULL);
+       if (boundintn) {
+           unsigned long boundint = yasm_intnum_get_uint(boundintn);
+
+           /* Alignments must be a power of two. */
+           if ((boundint & (boundint - 1)) == 0) {
+               if (boundint > yasm_section_get_align(parser_nasm->cur_section))
+                   yasm_section_set_align(parser_nasm->cur_section, boundint,
+                                          cur_line);
+           }
+       }
+
+       /* As this directive is called only when nop is used as fill, always
+        * use arch (nop) fill.
+        */
+       parser_nasm->prev_bc =
+           yasm_section_bcs_append(parser_nasm->cur_section,
+               yasm_bc_create_align(boundval, NULL, NULL,
+                   /*yasm_section_is_code(parser_nasm->cur_section) ?*/
+                       yasm_arch_get_fill(parser_nasm->arch)/* : NULL*/,
+                   cur_line));
     } else if (yasm__strcasecmp(name, "cpu") == 0) {
        yasm_vps_foreach(vp, valparams) {
            if (vp->val)
index 3e7e1cdc9056c537fd15ceaf84141f77b8c881e9..a435179869ea49cd0f41318bf786ce9b3eceb6ed 100644 (file)
@@ -3,6 +3,12 @@
 TESTS += modules/parsers/nasm/tests/nasm_test.sh
 
 EXTRA_DIST += modules/parsers/nasm/tests/nasm_test.sh
+EXTRA_DIST += modules/parsers/nasm/tests/alignnop16.asm
+EXTRA_DIST += modules/parsers/nasm/tests/alignnop16.errwarn
+EXTRA_DIST += modules/parsers/nasm/tests/alignnop16.hex
+EXTRA_DIST += modules/parsers/nasm/tests/alignnop32.asm
+EXTRA_DIST += modules/parsers/nasm/tests/alignnop32.errwarn
+EXTRA_DIST += modules/parsers/nasm/tests/alignnop32.hex
 EXTRA_DIST += modules/parsers/nasm/tests/endcomma.asm
 EXTRA_DIST += modules/parsers/nasm/tests/endcomma.errwarn
 EXTRA_DIST += modules/parsers/nasm/tests/endcomma.hex
diff --git a/modules/parsers/nasm/tests/alignnop16.asm b/modules/parsers/nasm/tests/alignnop16.asm
new file mode 100644 (file)
index 0000000..dd41361
--- /dev/null
@@ -0,0 +1,4 @@
+bits 16
+mov eax,32
+align 16
+ret
diff --git a/modules/parsers/nasm/tests/alignnop16.errwarn b/modules/parsers/nasm/tests/alignnop16.errwarn
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/modules/parsers/nasm/tests/alignnop16.hex b/modules/parsers/nasm/tests/alignnop16.hex
new file mode 100644 (file)
index 0000000..de32de7
--- /dev/null
@@ -0,0 +1,17 @@
+66 
+b8 
+20 
+00 
+00 
+00 
+eb 
+08 
+90 
+90 
+90 
+90 
+90 
+90 
+90 
+90 
+c3 
diff --git a/modules/parsers/nasm/tests/alignnop32.asm b/modules/parsers/nasm/tests/alignnop32.asm
new file mode 100644 (file)
index 0000000..13410d0
--- /dev/null
@@ -0,0 +1,4 @@
+bits 32
+mov eax,32
+align 16
+ret
diff --git a/modules/parsers/nasm/tests/alignnop32.errwarn b/modules/parsers/nasm/tests/alignnop32.errwarn
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/modules/parsers/nasm/tests/alignnop32.hex b/modules/parsers/nasm/tests/alignnop32.hex
new file mode 100644 (file)
index 0000000..4af43b8
--- /dev/null
@@ -0,0 +1,17 @@
+b8 
+20 
+00 
+00 
+00 
+eb 
+09 
+90 
+90 
+90 
+90 
+90 
+90 
+90 
+90 
+90 
+c3 
index fe6a49b1602e777e01167ad415f433defac5c943..85170cb214f05ba26c42ab5e35d9ccf18af8fe32 100644 (file)
@@ -65,7 +65,11 @@ __SECT__
 %endmacro
 
 %imacro align 1-2+.nolist nop
+%ifidni %2,nop
+         [align %1]
+%else
          times ($$-$) & ((%1)-1) %2
+%endif
 %endmacro
 %imacro alignb 1-2+.nolist resb 1
          times ($$-$) & ((%1)-1) %2