1

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
  • 286,368
  • 41
  • 520
  • 731
Michael Dadi
  • 342
  • 2
  • 11
  • 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

4

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

Seva Alekseyev
  • 58,089
  • 23
  • 157
  • 265
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
  • 334
  • 1
  • 4
  • 1
    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