diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2010-04-20 15:06:44 +0400 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2010-04-21 01:06:53 +0400 |
commit | 92aa187f3ab5228caa95494e30a7efc06288802e (patch) | |
tree | 8c887d40b03109367d2ddcf7d1f9350a1415fd94 | |
parent | d807d911feadad61c8afb09d74e4239859eba993 (diff) | |
download | nasm-92aa187f3ab5228caa95494e30a7efc06288802e.tar.gz nasm-92aa187f3ab5228caa95494e30a7efc06288802e.tar.bz2 nasm-92aa187f3ab5228caa95494e30a7efc06288802e.zip |
smartalign: Introduce nojmp mode
This allows to force nasm to generate multibyte
NOPs without jmp injected.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r-- | doc/nasmdoc.src | 5 | ||||
-rw-r--r-- | macros/smartalign.mac | 10 |
2 files changed, 10 insertions, 5 deletions
diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index d8c189b..3389b12 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 51779c6..32e7b3f 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__ |