.data
MemoryWord WORD 12
Result WORD ?
.code
main PROC
mov edi, OFFSET MemoryWord ; *Pointer
push ebp ; save the value of ebp in stack
mov ebp, esp ; set stack frame
; ebp now points to the top of the stack
push edi ; push *Pointer
call IncMemWord
mov Result, ax ; gets MemWord in ax
add esp, 4 ; Restore stack pointer
pop ebp ; Restore ebp
IncMemWord PROC
xor eax, eax
mov esi, [ebp-4 ; *Pointer
mov ax, [esi] ; MemWord = *Pointer
inc ax ; MemWord = MemWord + 1
mov [ebp-4], ax ; *Pointer = MemWord
ret ; return MemWord in ax
Comments
Leave a comment