Search code examples
cgccassemblyatt

assembly language tricky memory addresses


We are given the prompt (using AT&T ASM)

eax      = A

ebx      = B

ecx      = &X

edx      = &Y

I understand that (%eax) would grab the data in the memory location at A, but what would doing (%edx) grab? Say for example the call

 movl (%edx), %ebx

Also

movl %eax, (%ecx)

Does the first call just replace %ebx's current value with &Y (memory location of y) and the second call replace the data in the memory location &X with the value A?

What about the operation movl %edx, %eda? Does this just move the memory location of &Y into eax?

Thanks


Solution

  • From the 'C' language perspective:

    eax      = A
    

    eax gets a copy of the value of A.

    ebx      = B
    

    ebx gets a copy of the value of B.

    ecx      = &X
    

    ecx gets the address (or memory location) of X.

    edx      = &Y
    

    edx gets the address (or memory location) of y.