Most x86 instructions (other than some specialized instructions such as movsb
) can only access one memory location. Therefore a move from memory to memory requires going through a register with two mov
instructions.
The mov
instruction can be used in the following ways:
mov mem, reg
mov reg, mem
mov reg, reg
mov reg, imm
mov mem, imm
There is no mov mem, mem
.
Note that if you had compiled with optimizations, the variables would be placed in registers so this wouldn’t be an issue.