NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: jimcpl on June 05, 2009, 02:44:13 AM

Title: Assembling "mov esi,esp" - different results?
Post by: jimcpl on June 05, 2009, 02:44:13 AM
Hi,

I have a small assembled program (i.e., I have the binary) that does:

mov   esi,esp

to move the contents of the ESP register to the ESI register, and I'm trying to reproduce the source and then re-assembling using NASM.

However, the output from NASM is coming out as:

89E6

whereas the original binary has:

8BF4

What is the NASM source syntax that would assemble:

move  esi,esp

into 8BF4?

Thanks,
Jim
Title: Re: Assembling "mov esi,esp" - different results?
Post by: Frank Kotler on June 05, 2009, 10:00:26 AM
db 8Bh, 0F4h

... if you really need it "binary identical" to the original (let me guess... A386? or Tasm?). Does the same thing either way...

When you get into the nitty-gritty of instruction encoding, there's a "direction bit" (not to be confused with the "direction flag" bit in the flags register!), which essentially says "load esi from esp" or "store esp in esi". Nasm has no convenient way to indicate "do it the other way". Shouldn't matter.

Best,
Frank
Title: Re: Assembling "mov esi,esp" - different results?
Post by: A.B. on June 06, 2009, 01:30:11 PM
http://board.flatassembler.net/topic.php?t=6676 (http://board.flatassembler.net/topic.php?t=6676)
http://board.flatassembler.net/topic.php?t=6538 (http://board.flatassembler.net/topic.php?t=6538)
Title: Re: Assembling "mov esi,esp" - different results?
Post by: jimcpl on June 07, 2009, 04:00:56 AM
Frank and A.B.,

Thanks for the explanation (and links).

BTW, I was told that the source was originally assembled with NASM (which gave the 8bf4h), but that was awhile ago (is what I was told).  Is that possible?

Jim