The call instruction pushes the return address onto the stack, so when you pop ax in your procedure, it does not get the 7 you pressed, but the return address. ret won't work either (he expects to find the return address!) Try something like ...
FOOBAR proc push bp ; save caller reg mov bp, sp mov ax, [bp + 4] ; do something with it ; leave - equivalent to: mov sp, bp pop bp ret
There is a possible "booty." The βdistantβ procedure has both a segment (cs) and an offset in the stack, so 4 bytes for the return address, and two bytes for push bp put the first parameter in [bp + 6] . I think that only proc by default - proc near - you can say it just for clarity. If you need proc far , it's probably time to finish the 32-bit code (or 64-bit). The 16-bit code is such a PITA - we are really happy to forget it! :)
source share