From 92aa187f3ab5228caa95494e30a7efc06288802e Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Tue, 20 Apr 2010 15:06:44 +0400 Subject: [PATCH] smartalign: Introduce nojmp mode This allows to force nasm to generate multibyte NOPs without jmp injected. Signed-off-by: Cyrill Gorcunov --- doc/nasmdoc.src | 5 +++-- macros/smartalign.mac | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index d8c189bb..3389b12f 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -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 diff --git a/macros/smartalign.mac b/macros/smartalign.mac index 51779c64..32e7b3f2 100644 --- a/macros/smartalign.mac +++ b/macros/smartalign.mac @@ -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__ -- 2.11.4.GIT