smartalign: Introduce nojmp mode

This allows to force nasm to generate multibyte
NOPs without jmp injected.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2010-04-20 15:06:44 +04:00
parent d807d911fe
commit 92aa187f3a
2 changed files with 10 additions and 5 deletions

View 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

View 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__