compare PROTO, p1:DWORD, p2:DWORD
.code
compare proc p1:DWORD, p2:DWORD
mov eax, p1
mov edx, p2
mov eax, [eax] ;Getting an access violation here
mov edx, [edx] ; Would probably get one here too, why?
sub eax, edx
ret
compare endp
main PROC
LOCAL thesize:DWORD
mov thesize, 3
mov fill, 5
INVOKE compare, thesize, thesize
ret
main ENDP
嘿伙计们,只是好奇为什么这段代码不起作用?什么是使其工作的另一种方法,我只是在玩寄存器并在填充数组时尝试使用类似的代码,但此时我陷入困境。
提前致谢!
答案 0 :(得分:1)
不确定您在做什么,但由于您希望取消引用内存地址,因此必须使用addr
本地变量来获取/传递该地址。
main PROC
LOCAL thesize:DWORD
mov thesize, 3
; INVOKE compare, thesize, thesize
; same as:
; push 3
; push 3
; call compare
; this is what you want:
invoke compare, addr thesize, addr thesize
; same as:
; lea eax, thesize
; push eax
; push eax
; call compare
ret
main ENDP