Author Topic: Assembling "mov esi,esp" - different results?  (Read 18335 times)

jimcpl

  • Guest
Assembling "mov esi,esp" - different results?
« 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

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Assembling "mov esi,esp" - different results?
« Reply #1 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


jimcpl

  • Guest
Re: Assembling "mov esi,esp" - different results?
« Reply #3 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