I'm trying to sent DWORD variable into function as pointer paramater
variable1 dd 1
...
push [variable1] ; push variable adress
call _InitPoiner
...
_InitPoiner:
;
push ebp
mov ebp, esp
;
lea eax, [ebp+8] ; load address
mov dword [eax], 10 ; move value 10 into that address
pop ebp
ret
...
push [variable1]
push sdigit ; where sdigit db '%d', 0x0D, 0x0A, 0
call [printf]
but variable1 is 1, not 11 , why?
You are making sure that you pop your vars when done?
Looking at your example, I see no way that the variable could ever be 11. It starts as 1 at the dd
assignment, then if your math in the lea is correct, it would then be 10. If you were to step this through a debugger, you could check if your lea / mov
combo is working right. Either way, I would expect 1 or 10, not 11.
Maybe you meant to add
instead of mov
?