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

时间:2015-06-26 03:42:39

标签: assembly ia-32

有谁知道这里的错误解决方案是什么:

func PROC x:sdword, y:sdword
LOCAL tmp: sdword
...
func ENDP
  • 甲。 mov tmp, y
  • B中。 mov eax, y
  • ℃。 mov tmp, ecx
  • d。 lea eax, tmp

我可以使用所有这些指令,还是其中任何指令无效?

最诚挚的问候,谢谢

1 个答案:

答案 0 :(得分:0)

由于目标是要更好地理解,看看以下内容是否阐明了基本思想:

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.

相信这澄清了。