1

Hi guys im working on a CTF challenge and don't quite understand this asm command:

mov    %edx,0x20(%esp,%eax,4)

Im assuming its: move $edx into (0x20 + $esp + $eax + 4)

However when I checked this with gdb it isn't correct. Anyone mind explaining how this instruction works?

Thanks for your help!

lurker
  • 53,004
  • 8
  • 60
  • 93
Meraj Patel
  • 129
  • 4

1 Answers1

2

AT&T syntax for x86 memory references goes like this:

displacement(base,index,scale)

giving the address of displacement+base+(index*scale).

That is, destination memory address for your instuction is %ESP+0x20+(4*%EAX).

Anton Kovalenko
  • 19,333
  • 1
  • 33
  • 65