Search code examples
cassemblyaddressing-mode

Memory indirect addressing movl - assembly


I'm trying to understand how exactly memory indirect addressing works in assembly language with AT&T syntax.

movl (%eax), %ebx

movl %eax, (%ebx)

Here is a similar question that explains about memory indirect addressing

This is what I've understood:

In the first case, you load the data pointed to by the register %eax and store it in %ebx.

In the second case, you store the data in the register %eax to the address space pointed to by the register %ebx. Am I correct?


Solution

  • Basically the syntax is

    movl source, destination
    

    So movl (%eax), %ebx is indeed copy the value at address pointed to by %eax into %ebx. And movl %eax, (%ebx) is copy the value inside register %eax into the address pointed to by %ebx.

    So indeed your understanding is correct.