NASM 0.98p3.5
[nasm.git] / c16.mac
blob50b5d5eeb55fcb94539efd04b30fa2ba4e456c9a
1 ; NASM macro set to make interfacing to 16-bit programs easier -*- nasm -*-
5 %imacro proc 1                  ; begin a procedure definition
7 %push proc
9           global %1
11 %1:       push bp
13           mov bp,sp
15 %ifdef FARCODE PASCAL           ; arguments may start at bp+4 or bp+6
17 %assign %$arg 6
19 %define %$firstarg 6
21 %else
23 %assign %$arg 4
25 %define %$firstarg 4
27 %endif
29 %define %$procname %1
31 %endmacro
35 %imacro arg 0-1 2               ; used with the argument name as a label
37 %00       equ %$arg
39                                 ; we could possibly be adding some
41                                 ; debug information at this point...?
43 %assign %$arg %1+%$arg
45 %endmacro
49 %imacro endproc 0
51 %ifnctx proc
53 %error Mismatched `endproc'/`proc'
55 %else
57           mov sp,bp
59           pop bp
61 %ifdef PASCAL
63           retf %$arg - %$firstarg
65 %elifdef FARCODE
67           retf
69 %else
71           retn
73 %endif
75 __end_%$procname:               ; useful for calculating function size
77 %pop
79 %endif
81 %endmacro