The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: woonsan on October 19, 2008, 06:27:20 PM

Title: Encoding of NEG byte [0x10000000]
Post by: woonsan on October 19, 2008, 06:27:20 PM
I have gotten an interesting thing from the instruction encoding of NASM.

NEG byte [0x10000000], NEG word [0x10000000], whatever. This instruction is encoded differently in the 32-bit and 64-bit mode.
Actually, there is no form for the 64-bit addressing in displacement or immediate (Must be referenced by the 64-bit register addressing).

NEG byte [0x10000000] is encoded as
32: 0xF6 0x1D 0x00 0x00 0x00 0x10
64: 0xF6 0x1C 0x25 0x00 0x00 0x00 0x10

Both of them are valid in the 32-bit mode. And, I think that the code that NASM encoded in the 64-bit mode is not effecient.
NASM added an unnecessary SIB byte.

- Is there any reasons that NASM did so?
- Is 0xF6 0x1D 0x00 0x00 0x00 0x10 invalid in 64-bit systems?

Unfortunately, I do not currently have any 64-bit machines. So, I could not test it.

Thank you for reading my question.
Title: Re: Encoding of NEG byte [0x10000000]
Post by: woonsan on October 19, 2008, 07:57:41 PM
Sorry, I have gotten an answer after I read the manual again.
0xF6 0x1D ADDR was a RIP-relative addressing form.