c16.mac 872 B

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