Assembly 将参数移动到局部变量和LEA指令

Assembly 将参数移动到局部变量和LEA指令,assembly,x86,Assembly,X86,有人知道什么是错误的解决方案吗: func PROC x:sdword, y:sdword LOCAL tmp: sdword ... func ENDP A.mov tmp,y B.mov eax,y C.mov tmp、ecx D.leaeax,tmp 我可以使用所有这些说明吗,或者其中任何一个是无效的 向您致以最良好的问候和感谢因为我们的目标是更好地理解,请查看以下内容是否阐明了基本想法: 1. mov y,tmp ; This is not legal in Intel x64 (

有人知道什么是错误的解决方案吗:

func PROC x:sdword, y:sdword
LOCAL tmp: sdword
...
func ENDP
  • A.
    mov tmp,y
  • B.
    mov eax,y
  • C.
    mov tmp、ecx
  • D.
    leaeax,tmp
我可以使用所有这些说明吗,或者其中任何一个是无效的


向您致以最良好的问候和感谢

因为我们的目标是更好地理解,请查看以下内容是否阐明了基本想法:

1. mov y,tmp ; This is not legal in Intel x64 (or x86)
2. mov eax,y ; This is perfectly fine. An advice : use mov eax, dword ptr y
3. mov tmp,ecx  ; again, is perfectly fine. However, mov dword ptr tmp,ecx is easier to track during debugging
4. lea eax,tmp ; This is not wrong - only this loads the address of the variable tmp into eax, if your next instruction would have been, say
4' : mov ecx, dword ptr [eax], you would be loading the content of the memory address tmp into ecx.

相信这会澄清问题。

什么是错误的解决方案?哪条指令是错误的。如果我想将其中一条指令替换为“…”,哪条指令是错误的?逻辑上、语法上是错误的?此函数试图实现什么?
mov tmp,y
错误。假设MASM和32位C调用约定,
tmp
将被转换为
[ebp-4]
y
将被转换为
[ebp+12]
。结果是
mov[ebp-4],[ebp+12]
-一种内存对内存的操作。x86处理器无法执行此类操作。