组装:两个内存地址之间移动 [英] Assembly: MOVing between two memory addresses
问题描述
我想学assermbly(如此忍受我),我在这条线得到一个编译错误:
I'm trying to learn assermbly (so bear with me) and I'm getting a compile error on this line:
mov byte [t_last], [t_cur]
该错误是
error: invalid combination of opcode and operands
我怀疑,这个错误的原因很简单,它不可能MOV指令两个内存地址之间移动,但谷歌搜索的一个半小时,我一直没能证实这一点 - 是这样的话?
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)?
推荐答案
您的怀疑是正确的,你不能从内存移动到内存中。
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.
这篇关于组装:两个内存地址之间移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!