previous | start | next

The IA32 movl and addl instructions

If an operand is in memory, an instruction might want to know just the location (i.e., in order to store some value there).

 movl %eax, -4(%ebp)  ; move contents of %eax to memory location -4(%ebp)

 M[-4(%ebp)] = R[%eax]
   

On the other hand, if the first operand of movl is a memory location, it moves the contents to the destination register.

 movl -4(%ebp), %eax

 R[%eax] = M[-4(%ebp)]     
   

An add instruction would need to know both the values stored at the locations of its operands and the location of the second operand:

 addl %eax, -4(%ebp)  ; add contents of memory register %eax to location -4(%ebp).      

 M[-4(%ebp)] = M[-4(%ebp)] + R[%eax]
   

Note: In both cases these instructions need the contents of the first operand!



previous | start | next