1

What does 0x4 from the following assembly line mean?

cmp 0x4(%esi),%ebx
je ...

When this compare returns equal and the jump is performed the registers have the values: %esi 0xe944d6d0 %ebx 0xe94ceccc

Sorry for asking such a simple question but I'm having a hard time searching such paranthesis notation with google. Spent more than half an hour while under time pressure.

nrz
  • 10,435
  • 4
  • 39
  • 71
George
  • 1,027
  • 3
  • 12
  • 20
  • 1
    If you aren't comfortable with AT&T syntax, you can switch to Intel syntax. http://stackoverflow.com/a/972614/1354557 – user1354557 Feb 14 '13 at 16:22
  • Possible duplicate of [What exactly is this line doing: add -0x4(%esi,%ebx,4),%eax?](https://stackoverflow.com/questions/28848554/what-exactly-is-this-line-doing-add-0x4esi-ebx-4-eax) – phuclv Aug 09 '18 at 01:30

1 Answers1

3

That is AT&T syntax, in Intel syntax it would be:

cmp ebx,[esi+4]

Note that the order of operands is reversed.

In Intel syntax it's dest, src. In AT&T it's src, dest.

So basically that instruction compares ebx with the dword value stored in [esi+4] by subtracting the dword value stored in [esi+4] from ebx, just like sub would do, but cmp only updates flags, it doesn't store the result anywhere.

nrz
  • 10,435
  • 4
  • 39
  • 71