Advertisement
MichaelPetch

IBM MASM exit

Sep 3rd, 2022
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. stack segment stack
  2. db 80h dup(?)
  3. stack ends
  4.  
  5. data segment
  6. data ends
  7.  
  8. code segment
  9.  
  10. main proc far
  11. push ds ; DS = PSP, save PSP segment on stack
  12.  
  13. ; Insert program code here.
  14. ; Make sure the stack is balanced when finished
  15. ; -----------------
  16. assume cs:code,ds:data
  17. mov dx, @data
  18. mov ds, dx
  19. ; -----------------
  20.  
  21. ; Exit EXE program with FAR Return to PSP_Segment:0000h where
  22. ; an Into 20h resides in the word at offset 0000h in the PSP
  23.  
  24. xor ax, ax ; AX = 0
  25. push ax ; Push 0 on the stack
  26. ; Note: `PUSH` with an immediate value
  27. ; wasn't a valid instruction on
  28. ; Intel 8088/8086 processors
  29.  
  30. ; At this point the DS (PSP) pushed at the beginning of the program
  31. ; and the value 0000h forms a CS:IP FAR pointer on the stack
  32.  
  33. ret ; Return to PSP_Segment:0000h via FAR pointer
  34. ; on the stack and execute
  35. ; the Int 20h at that address
  36. main endp
  37. code ends
  38.  
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement