1; Standard macro set for NASM -*- nasm -*-
2
3; Note that although some user-level forms of directives are defined
4; here, not all of them are: the user-level form of a format-specific
5; directive should be defined in the module for that directive.
6
7; These two need to be defined, though the actual definitions will
8; be constantly updated during preprocessing.
9%define __FILE__
10%define __LINE__
11
12%define __SECT__ [section .text] ; it ought to be defined, even if as nothing
13
14%imacro section 1+.nolist
15%define __SECT__ [section %1]
16	  __SECT__
17%endmacro
18%imacro segment 1+.nolist
19%define __SECT__ [segment %1]
20	  __SECT__
21%endmacro
22
23%imacro absolute 1+.nolist
24%define __SECT__ [absolute %1]
25	  __SECT__
26%endmacro
27
28%imacro struc 1-2.nolist 0
29%push struc
30%define %$strucname %1
31[absolute %2]
32%$strucname:			; allow definition of `.member' to work sanely
33%endmacro 
34%imacro endstruc 0.nolist
35%{$strucname}_size EQU $ - %$strucname
36%pop
37__SECT__
38%endmacro
39
40%imacro istruc 1.nolist
41%push istruc
42%define %$strucname %1
43%$strucstart:
44%endmacro
45%imacro at 1-2+.nolist
46	  times %1-($-%$strucstart) db 0
47	  %2
48%endmacro
49%imacro iend 0.nolist
50	  times %{$strucname}_size-($-%$strucstart) db 0
51%pop
52%endmacro
53
54%imacro align 1-2+.nolist nop
55%ifidni %2,nop
56	  [align %1]
57%else
58	  times ($$-$) & ((%1)-1) %2
59%endif
60%endmacro
61%imacro alignb 1-2+.nolist resb 1
62	  times ($$-$) & ((%1)-1) %2
63%endmacro
64
65%imacro extern 1-*.nolist
66%rep %0
67[extern %1]
68%rotate 1
69%endrep
70%endmacro
71
72%imacro bits 1+.nolist
73[bits %1]
74%endmacro
75
76%imacro use16 0.nolist
77[bits 16]
78%endmacro
79%imacro use32 0.nolist
80[bits 32]
81%endmacro
82%imacro use64 0.nolist
83[bits 64]
84%endmacro
85
86%imacro global 1-*.nolist
87%rep %0
88[global %1]
89%rotate 1
90%endrep
91%endmacro
92
93%imacro common 1-*.nolist
94%rep %0
95[common %1]
96%rotate 1
97%endrep
98%endmacro
99
100%imacro cpu 1+.nolist
101[cpu %1]
102%endmacro
103
104%imacro default 1+.nolist
105[default %1]
106%endmacro
107
108; NASM compatibility shim
109%define __OUTPUT_FORMAT__ __YASM_OBJFMT__
110