outcoff: BR 2685756: fix SAFESEH with an internal symbol
[nasm/perl-rewrite.git] / standard.mac
blob0faa1876575152e89a0412820f41133119dc8f8e
1 ; Standard macro set for NASM -*- nasm -*-
3 ; Macros to make NASM ignore some TASM directives before the first include
4 ; directive.
6     %idefine IDEAL
7     %idefine JUMPS
8     %idefine P386
9     %idefine P486
10     %idefine P586
11     %idefine END
13 ; This is a magic token which indicates the end of the TASM macros
14 *END*TASM*MACROS*
16 ; Note that although some user-level forms of directives are defined
17 ; here, not all of them are: the user-level form of a format-specific
18 ; directive should be defined in the module for that directive.
20 ; These three need to be defined, though the actual definitions will
21 ; be constantly updated during preprocessing.
22 %define __FILE__
23 %define __LINE__
24 %define __BITS__
26 %define __SECT__                ; it ought to be defined, even if as nothing
28 %imacro section 1+.nolist
29 %define __SECT__ [section %1]
30           __SECT__
31 %endmacro
32 %imacro segment 1+.nolist
33 %define __SECT__ [segment %1]
34           __SECT__
35 %endmacro
37 %imacro absolute 1+.nolist
38 %define __SECT__ [absolute %1]
39           __SECT__
40 %endmacro
42 %imacro struc 1.nolist
43 %push
44 %define %$strucname %1
45 [absolute 0]
46 %$strucname:                    ; allow definition of `.member' to work sanely
47 %endmacro 
48 %imacro endstruc 0.nolist
49 %{$strucname}_size:
50 %pop
51 __SECT__
52 %endmacro
54 %imacro istruc 1.nolist
55 %push
56 %define %$strucname %1
57 %$strucstart:
58 %endmacro
59 %imacro at 1-2+.nolist
60           times %1-($-%$strucstart) db 0
61           %2
62 %endmacro
63 %imacro iend 0.nolist
64           times %{$strucname}_size-($-%$strucstart) db 0
65 %pop
66 %endmacro
68 %imacro align 1-2+.nolist nop
69           times (((%1) - (($-$$) % (%1))) % (%1)) %2
70 %endmacro
71 %imacro alignb 1-2+.nolist
72           %ifempty %2
73                 resb (((%1) - (($-$$) % (%1))) % (%1))
74           %else
75                 times (((%1) - (($-$$) % (%1))) % (%1)) %2
76           %endif
77 %endmacro
79 %imacro extern 1-*.nolist
80 %rep %0
81 [extern %1]
82 %rotate 1
83 %endrep
84 %endmacro
86 %imacro bits 1+.nolist
87 [bits %1]
88 %endmacro
90 %imacro use16 0.nolist
91 [bits 16]
92 %endmacro
93 %imacro use32 0.nolist
94 [bits 32]
95 %endmacro
96 %imacro use64 0.nolist
97 [bits 64]
98 %endmacro
100 %imacro global 1-*.nolist
101 %rep %0
102 [global %1]
103 %rotate 1
104 %endrep
105 %endmacro
107 %imacro common 1-*.nolist
108 %rep %0
109 [common %1]
110 %rotate 1
111 %endrep
112 %endmacro
114 %imacro cpu 1+.nolist
115 [cpu %1]
116 %endmacro
118 %define __FLOAT_DAZ__ nodaz
119 %define __FLOAT_ROUND__ near
120 ; __FLOAT__ contains the whole floating-point configuration so it can
121 ; be saved and restored
122 %define __FLOAT__ __FLOAT_DAZ__,__FLOAT_ROUND__
123 %imacro float 1-*.nolist
124 %rep %0
125 [float %1]
126 %ifidni %1,daz
127 %define __FLOAT_DAZ__ daz
128 %elifidni %1,nodaz
129 %define __FLOAT_DAZ__ nodaz
130 %elifidni %1,near
131 %define __FLOAT_ROUND__ near
132 %elifidni %1,up
133 %define __FLOAT_ROUND__ up
134 %elifidni %1,down
135 %define __FLOAT_ROUND__ down
136 %elifidni %1,zero
137 %define __FLOAT_ROUND__ zero
138 %elifidni %1,default
139 %define __FLOAT_DAZ__ nodaz
140 %define __FLOAT_ROUND__ near
141 %endif
142 %rotate 1
143 %endrep
144 %endmacro
146 %imacro default 1+.nolist
147 [default %1]
148 %endmacro
150 %imacro incbin 1-2+.nolist 0
151 %push
152 %pathsearch %$dep %1
153 %depend %$dep
154         %? %$dep,%2
155 %pop
156 %endmacro