0

lets say, %eax has content 0x123 and 0x123 has content 0x987. and address 0xabc has content 0x100.

then, with movl (%eax), 0xabc, won't 0x987 be moved as the content of 0xabc? why do we need another register to do this? i.e.

movl (%eax), %eax    
movl %eax, 0xabc

Similarly, movl 0xabc, (%eax) won't it move 0x100 to the address of %eax i.e. 0x123?? do we need another register as well to perform this?

ABJ
  • 31
  • 5

1 Answers1

1

It's because x86 doesn't offer memory-to-memory simple mov instruction. The can see all the offered forms here and scanning the list you'll see essentially load (move from memory), store (move to memory) and register-register forms, but none that both load and store from memory.

x86 does offer more complex instructions such as movsd that do load and store from memory: that one, for example, moves 4 bytes from rsi to rdi. These probably don't really help in your scenario though: they still need two registers for the addresses as there are no "immediate" forms for the address. They are largely useful only in their rep movs forms to do a variable-length memory copy.

BeeOnRope
  • 60,350
  • 16
  • 207
  • 386