Using stack in windows MASM program

175 views Asked by At

I'm writing simple MASM application in WinAsm Studio and I encountered a problem with the stack.
I've been able to recreate it in this very simple program:

.386
.model flat, stdcall
OPTION CASEMAP:NONE 

Include windows.inc
Include kernel32.inc
Include masm32.inc
include user32.inc
IncludeLib kernel32.lib
IncludeLib masm32.lib
IncludeLib user32.lib 

.code
aProc proc near
  push 1
  ret
aProc endp

bProc proc near
  pop edx
  ret
bProc endp

start:
  call aProc
  call bProc
  invoke ExitProcess, 0
end start

What I'm trying to do in this example is to put a few values onto the stack in one procedure (aProc) and then retrieve them in another procedure (bProc).

Can you explain to me why this code causes the program to crash (Access violation) and how to use the stack properly?

0

There are 0 answers