NASM Forum > Programming with NASM
same instruction different opcodes
billium:
Hello All
About 3 years ago I did some reverse engineering on some V40 code, made some minor modifications then reassembled using NASM:
--- Code: --- 744 loc_F84A4:
745 000004A4 FA cli
746 000004A5 F7040100 test word [si], 1
747 000004A9 7528 jnz short loc_F84D3
748 000004AB FB sti
749 000004AC 810C0100 or word [si], 1
750 000004B0 8B5C08 mov bx, [si+8]
751 000004B3 8A400A mov al, [bx+si+0Ah]
752 000004B6 43 inc bx
753 000004B7 81E3FF00 and bx, 0FFh
754 000004BB 895C08 mov [si+8], bx
755 000004BE FF4C04 dec word [si+4]
756 000004C1 86C4 xchg al, ah
757
758 loc_F84C3:
759 000004C3 E4C1 in al, 0C1h
760
--- End code ---
As can be seen in the above listing the loc_F8*** align with the generated address and the or word [si], 1 instruction gives a word for 1.
Now, I needed to do another minor mod, assembled with NASM again but noticed the loc_F8s were no longer aligned. I then noticed the or instruction only gave a byte for 1:
--- Code: --- 690 000004AC 830C01 or word [si], 1
--- End code ---
I am not modding this code so I do not know, nor need to know what it does, but I do need to keep alignment, as I do not want to go through the whole code.
Can anbody see what I am doing wrong to get the different result? I assume it is some sort of optimisation, can I force NASM to use the first type of or listed above. There are many of these in the whole listing.
Many
billium:
It is o.k. you can all stop paniking for me now I found the problem. :)
It looks like -O0 is not default in NASM version 2.09.10.
Many thanks
Billy
wyvern666:
mmmm, are you sure 2.09.10?, look this output:
--- Quote --->NASM -v
NASM version 2.09.10 compiled on Jul 15 2011
>NASM -h
usage: nasm [-@ response file] [-o outfile] [-f format] [-l listfile]
[options...] [--] filename
or nasm -v for version info
...
-O<digit> optimize branch offsets
-O0: No optimization (default)
-O1: Minimal optimization
-Ox: Multipass optimization (recommended)
...
--- End quote ---
billium:
Yes I copied/pasted from the v command.
That is why I posted here instead of just using -O0, because I read it was default.
--- Code: ---NASM version 2.09.10 compiled on Aug 18 2011
--- End code ---
Billy
Frank Kotler:
'Tis true, the help screen lies. The default is now "-Ox". Worse, the "align" directive seems broken. "align 512" works, but "align 200h" claims not to be a power of two! 0.2.10rc8 seems to have "align" fixed, but the help screen still claims "-O0" is default. Sorry 'bout that!
Best,
Frank
Navigation
[0] Message Index
[#] Next page
Go to full version