smartalign: Introduce nojmp mode
authorCyrill Gorcunov <gorcunov@gmail.com>
Tue, 20 Apr 2010 11:06:44 +0000 (15:06 +0400)
committerCyrill Gorcunov <gorcunov@gmail.com>
Tue, 20 Apr 2010 21:06:53 +0000 (01:06 +0400)
This allows to force nasm to generate multibyte
NOPs without jmp injected.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
doc/nasmdoc.src
macros/smartalign.mac

index d8c189b..3389b12 100644 (file)
@@ -4073,8 +4073,9 @@ sequence.
 
 The specific instructions generated can be controlled with the
 new \i\c{ALIGNMODE} macro.  This macro takes two parameters: one mode,
-and an optional jump threshold override.  The modes are as
-follows:
+and an optional jump threshold override. If (for any reason) you need
+to turn off the jump completely just set jump threshold value to -1.
+The following modes are possible:
 
 \b \c{generic}: Works on all x86 CPUs and should have reasonable
 performance.  The default jump threshold is 8.  This is the
index 51779c6..32e7b3f 100644 (file)
@@ -150,7 +150,11 @@ USE: smartalign
     %error unknown alignment mode: %1
   %endif
   %ifnempty %2
-    %xdefine __ALIGN_JMP_THRESHOLD__ %2
+    %ifidni %2,nojmp
+      %xdefine __ALIGN_JMP_THRESHOLD__ -1
+    %else
+      %xdefine __ALIGN_JMP_THRESHOLD__ %2
+    %endif
   %endif
   %xdefine __ALIGNMODE__ %1,__ALIGN_JMP_THRESHOLD__
 %endmacro
@@ -162,14 +166,14 @@ USE: smartalign
   %else
     %push
     %assign %$pad (((%1) - (($-$$) % (%1))) % (%1))
-    %if %$pad > __ALIGN_JMP_THRESHOLD__
+    %if __ALIGN_JMP_THRESHOLD__ != -1 && %$pad > __ALIGN_JMP_THRESHOLD__
       jmp %$end
       ; We can't re-use %$pad here as $ will have changed!
       times (((%1) - (($-$$) % (%1))) % (%1)) nop
 %$end:
     %else
       times (%$pad / __ALIGN_%[__BITS__]BIT_GROUP__) \
-       db __ALIGN_%[__BITS__]BIT_%[__ALIGN_%[__BITS__]BIT_GROUP__]B__
+        db __ALIGN_%[__BITS__]BIT_%[__ALIGN_%[__BITS__]BIT_GROUP__]B__
       %assign %$pad %$pad % __ALIGN_%[__BITS__]BIT_GROUP__
       %if %$pad > 0
         db __ALIGN_%[__BITS__]BIT_%[%$pad]B__