In MASM, I want to send my variable num1
to a function and have it modify the original value num1
it is holding. I want to accomplish this by using addr
operator. The output here need to be 6, instead of 2. But what I am getting is 2 despite trying to change the original value.
.386
.model flat, stdcall
.stack 4096
ExitProcess proto, dwExitCode:dword
include Irvine32.inc
.data
num1 dword 2
.code
modify PROC var : DWORD
mov eax, 6
mov [var], eax
ret
modify endp
main proc
; Call modify and pass the address of num1
invoke modify, addr num1
; Print the updated value directly from num1
mov eax, num1 ;Error, after the function call, num1 doesn't have the updated value of 6
call WriteDec
call Crlf
invoke ExitProcess, 0
main endp
end main
5