2

What exactly is the difference resulting from a register being surrounded in parentheses in an operation?

For example:

movl (%edx), %eax

versus

movl %edx, %eax

Thank you in advance!

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Michael Dadi
  • 362
  • 3
  • 12
  • Take a look at this: https://stackoverflow.com/questions/59629710/difference-between-sp-and-sp-in-assembly – Suraaj K S Apr 03 '20 at 05:55
  • It's indirect addressing mode. where the value stored under in register %edx will be treated as memory address and the value stored in that address will be copied to %eax. – Niranjan M.R Apr 03 '20 at 07:26

2 Answers2

6

Means "the memory at the address that's stored in the register".

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
2

Move from one register to another, eax to edx edx to eax.

movl %edx, %eax

Move from eax to memory address contained in edx.
Move from memory address contained in edx to eax.

movl (%edx), %eax

How you could find out by youself: search for 'x86 assembly syntax' This page was one of the results.

ranga
  • 372
  • 1
  • 4
  • 2
    Are you sure you got that right? The AT&T syntax is `mov source, destination`. So your first example would move the value from the `edx` register to the `eax` register. I'm assuming AT&T syntax because the Intel syntax doesn't prefix the registers with `%`. – Jim Mischel Apr 03 '20 at 21:51
  • 1
    @JimMischel right, thank you for correcting. – ranga Apr 04 '20 at 05:15