home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / nasm097.zip / MISC / C16.MAC next >
Text File  |  1997-10-01  |  729b  |  38 lines

  1. ; NASM macro set to make interfacing to 16-bit programs easier -*- nasm -*-
  2.  
  3. %imacro proc 1            ; begin a procedure definition
  4. %push proc
  5.       global %1
  6. %1:      push bp
  7.       mov bp,sp
  8. %ifdef FARCODE PASCAL        ; arguments may start at bp+4 or bp+6
  9. %assign %$arg 6
  10. %else
  11. %assign %$arg 4
  12. %endif
  13. %define %$procname %1
  14. %endmacro
  15.  
  16. %imacro arg 0-1 2        ; used with the argument name as a label
  17.       equ %$arg
  18. %assign %$arg %1+%$arg
  19. %endmacro
  20.  
  21. %imacro endproc 0
  22. %ifnctx proc
  23. %error Mismatched `endproc'/`proc'
  24. %else
  25.           mov sp,bp
  26.           pop bp
  27. %ifdef PASCAL
  28.           retf %$arg
  29. %elifdef FARCODE
  30.       retf
  31. %else
  32.       retn
  33. %endif
  34. __end_%$procname:        ; useful for calculating function size
  35. %pop
  36. %endif
  37. %endmacro
  38.