Update documentation
[platform/upstream/nasm.git] / misc / c16.mac
1 ; NASM macro set to make interfacing to 16-bit programs easier -*- nasm -*-
2
3
4
5 %imacro proc 1                  ; begin a procedure definition
6
7 %push proc
8
9           global %1
10
11 %1:       push bp
12
13           mov bp,sp
14
15 %ifdef FARCODE PASCAL           ; arguments may start at bp+4 or bp+6
16
17 %assign %$arg 6
18
19 %define %$firstarg 6
20
21 %else
22
23 %assign %$arg 4
24
25 %define %$firstarg 4
26
27 %endif
28
29 %define %$procname %1
30
31 %endmacro
32
33
34
35 %imacro arg 0-1 2               ; used with the argument name as a label
36
37 %00       equ %$arg
38
39                                 ; we could possibly be adding some
40
41                                 ; debug information at this point...?
42
43 %assign %$arg %1+%$arg
44
45 %endmacro
46
47
48
49 %imacro endproc 0
50
51 %ifnctx proc
52
53 %error Mismatched `endproc'/`proc'
54
55 %else
56
57           mov sp,bp
58
59           pop bp
60
61 %ifdef PASCAL
62
63           retf %$arg - %$firstarg
64
65 %elifdef FARCODE
66
67           retf
68
69 %else
70
71           retn
72
73 %endif
74
75 __end_%$procname:               ; useful for calculating function size
76
77 %pop
78
79 %endif
80
81 %endmacro
82