MOVing between two memory addresses
assembly, instructions, mov, x86
Solution
Your suspicion is correct, you can't move from memory to memory.
Any general-purpose register will do. Remember to PUSH the register if you are not sure what's inside it and to restore it back once done.
Problem
I'm trying to learn assembly (so bear with me) and I'm getting a compile error on this line: ``` mov byte [t_last], [t_cur] ``` The error is ``` error: invalid combination of opcode and operands ``` I suspect that the cause of this error is simply that its not possible for a mov instruction to move between two memory addresses, but half an hour of googling and I haven't been able to confirm this - is this the case? Also, assuming I'm right that means I need to use a register as an intermediate point for copying memory: ``` mov cl, [t_cur] mov [t_last], cl ``` Whats the recommended register to use (or should I use the stack instead)?
Related problems
- Why doesn't GCC use partial registers?
- How exactly do partial registers on Haswell/Skylake perform? Writing AL seems to have a false dependency on RAX, and AH is inconsistent
- What x86 instructions take two (or more) memory operands?
- Why can't MOV have both operands as memory locations?
- Why isn't movl from memory to memory allowed?