rbtree: add rb_search_exact()
[nasm.git] / macros / standard.mac
bloba2ab4fc1985af84259132339b6f46bee55eb3e0d
1 ;; --------------------------------------------------------------------------
2 ;;   
3 ;;   Copyright 1996-2019 The NASM Authors - All Rights Reserved
4 ;;   See the file AUTHORS included with the NASM distribution for
5 ;;   the specific copyright holders.
6 ;;
7 ;;   Redistribution and use in source and binary forms, with or without
8 ;;   modification, are permitted provided that the following
9 ;;   conditions are met:
11 ;;   * Redistributions of source code must retain the above copyright
12 ;;     notice, this list of conditions and the following disclaimer.
13 ;;   * Redistributions in binary form must reproduce the above
14 ;;     copyright notice, this list of conditions and the following
15 ;;     disclaimer in the documentation and/or other materials provided
16 ;;     with the distribution.
18 ;;     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 ;;     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 ;;     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 ;;     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 ;;     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 ;;     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 ;;     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 ;;     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 ;;     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 ;;     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 ;;     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 ;;     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 ;;     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 ;; --------------------------------------------------------------------------
34 ; Standard macro set for NASM -*- nasm -*-
36 ; Macros to make NASM ignore some TASM directives
37 STD: tasm
38     %idefine IDEAL
39     %idefine JUMPS
40     %idefine P386
41     %idefine P486
42     %idefine P586
43     %idefine END
45 ; The normal standard macros
46 STD: nasm
48 ; Note that although some user-level forms of directives are defined
49 ; here, not all of them are: the user-level form of a format-specific
50 ; directive should be defined in the module for that directive.
52 %define __?SECT?__            ; it ought to be defined, even if as nothing
53 %defalias __SECT__ __?SECT?__
55 %imacro section 1+.nolist
56     %define __?SECT?__ [section %1]
57     __?SECT?__
58 %endmacro
60 %imacro segment 1+.nolist
61     %define __?SECT?__ [segment %1]
62     __?SECT?__
63 %endmacro
65 %define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 1
66 %imacro sectalign 1+.nolist
67     %ifidni %1,off
68         %define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 0
69     %elifidni %1,on
70         %define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 1
71     %else
72         [sectalign %1]
73     %endif
74 %endmacro
75 %defalias __SECTALIGN_ALIGN_UPDATES_SECTION__ __?SECTALIGN_ALIGN_UPDATES_SECTION?__
77 %imacro absolute 1+.nolist
78     %define __?SECT?__ [absolute %1]
79     __?SECT?__
80 %endmacro
82 %imacro struc 1-2.nolist 0
83     %push
84         %define %$strucname %1
85         [absolute %2]
86         %$strucname:        ; allow definition of `.member' to work sanely
87 %endmacro
89 %imacro endstruc 0.nolist
90         %{$strucname}_size equ ($-%$strucname)
91     %pop
92     __?SECT?__
93 %endmacro
95 %imacro istruc 1.nolist
96     %push
97         %define %$strucname %1
98         %$strucstart:
99 %endmacro
101 %imacro at 1-2+.nolist
102     times (%1-%$strucname)-($-%$strucstart) db 0
103     %2
104 %endmacro
106 %imacro iend 0.nolist
107         times %{$strucname}_size-($-%$strucstart) db 0
108     %pop
109 %endmacro
111 %imacro align 1-2+.nolist nop
112     %if __?SECTALIGN_ALIGN_UPDATES_SECTION?__
113         sectalign %1
114     %endif
115     times (((%1) - (($-$$) % (%1))) % (%1)) %2
116 %endmacro
118 %imacro alignb 1-2+.nolist
119     %if __?SECTALIGN_ALIGN_UPDATES_SECTION?__
120         sectalign %1
121     %endif
122     %ifempty %2
123         [warning push]
124         [warning -zeroing]
125         resb (((%1) - (($-$$) % (%1))) % (%1))
126         [warning pop]
127     %else
128         times (((%1) - (($-$$) % (%1))) % (%1)) %2
129     %endif
130 %endmacro
132 %imacro bits 1+.nolist
133     [bits %1]
134 %endmacro
136 %imacro use16 0.nolist
137     [bits 16]
138 %endmacro
140 %imacro use32 0.nolist
141     [bits 32]
142 %endmacro
144 %imacro use64 0.nolist
145     [bits 64]
146 %endmacro
148 %imacro extern 1-*.nolist
149     %rep %0
150         [extern %1]
151         %rotate 1
152     %endrep
153 %endmacro
155 %imacro static 1-*.nolist
156     %rep %0
157         [static %1]
158         %rotate 1
159     %endrep
160 %endmacro
162 %imacro global 1-*.nolist
163     %rep %0
164         [global %1]
165         %rotate 1
166     %endrep
167 %endmacro
169 %imacro required 1-*.nolist
170     %rep %0
171         [required %1]
172         %rotate 1
173     %endrep
174 %endmacro
176 %imacro common 1-*.nolist
177     %rep %0
178         [common %1]
179         %rotate 1
180     %endrep
181 %endmacro
183 %imacro cpu 1+.nolist
184     [cpu %1]
185 %endmacro
187 %define __?FLOAT_DAZ?__ nodaz
188 %define __?FLOAT_ROUND?__ near
189 ; __?FLOAT?__ contains the whole floating-point configuration so it can
190 ; be saved and restored
191 %define __?FLOAT?__ __?FLOAT_DAZ?__,__?FLOAT_ROUND?__
193 %defalias __FLOAT_DAZ__ __?FLOAT_DAZ?__
194 %defalias __FLOAT_ROUND__ __?FLOAT_ROUND?__
195 %defalias __FLOAT__ __?FLOAT?__
197 %imacro float 1-*.nolist
198     %rep %0
199         [float %1]
200         %ifidni %1,daz
201             %define __?FLOAT_DAZ?__ daz
202         %elifidni %1,nodaz
203             %define __?FLOAT_DAZ?__ nodaz
204         %elifidni %1,near
205             %define __?FLOAT_ROUND?__ near
206         %elifidni %1,up
207             %define __?FLOAT_ROUND?__ up
208         %elifidni %1,down
209             %define __?FLOAT_ROUND?__ down
210         %elifidni %1,zero
211             %define __?FLOAT_ROUND?__ zero
212         %elifidni %1,default
213             %define __?FLOAT_DAZ?__ nodaz
214             %define __?FLOAT_ROUND?__ near
215         %endif
216         %rotate 1
217     %endrep
218 %endmacro
220 %imacro default 1+.nolist
221     [default %1]
222 %endmacro
224 %imacro userel 0.nolist
225     [default rel]
226 %endmacro
227 %imacro useabs 0.nolist
228     [default abs]
229 %endmacro
230 %imacro usebnd 0.nolist
231     [default bnd]
232 %endmacro
233 %imacro usenobnd 0.nolist
234     [default nobnd]
235 %endmacro
237 %imacro incbin 1-2+.nolist 0
238     %push
239         %pathsearch %$dep %1
240         %depend %$dep
241         %? %$dep,%2
242     %pop
243 %endmacro
245 ; Compatibility macro aliases
246 %defalias __NASM_MAJOR__      __?NASM_MAJOR?__
247 %defalias __NASM_MINOR__      __?NASM_MINOR?__
248 %defalias __NASM_SUBMINOR__   __?NASM_SUBMINOR?__
249 %defalias __NASM_PATCHLEVEL__ __?NASM_PATCHLEVEL?__
250 %defalias __NASM_SNAPSHOT__   __?NASM_SNAPSHOT?__
251 %defalias __NASM_VERSION_ID__ __?NASM_VERSION_ID?__
252 %defalias __NASM_VER__        __?NASM_VER?__
254 %defalias __OUTPUT_FORMAT__   __?OUTPUT_FORMAT?__
255 %defalias __DEBUG_FORMAT__    __?DEBUG_FORMAT?__
257 %defalias __DATE__            __?DATE?__
258 %defalias __DATE_NUM__        __?DATE_NUM?__
259 %defalias __TIME__            __?TIME?__
260 %defalias __TIME_NUM__        __?TIME_NUM?__
261 %defalias __UTC_DATE__        __?UTC_DATE?__
262 %defalias __UTC_DATE_NUM__    __?UTC_DATE_NUM?__
263 %defalias __UTC_TIME__        __?UTC_TIME?__
264 %defalias __UTC_TIME_NUM__    __?UTC_TIME_NUM?__
265 %defalias __POSIX_TIME__      __?POSIX_TIME?__
267 %defalias __FILE__            __?FILE?__
268 %defalias __LINE__            __?LINE?__
269 %defalias __BITS__            __?BITS?__
270 %defalias __PTR__             __?PTR?__
271 %defalias __PASS__            __?PASS?__
273 ; Backwards compatiblity aliases for tokens. The extra level of indirection here
274 ; means %aliases on|off will do the right thing for these as well.
275 %idefine __?infinity?__ %?
276 %idefine __?nan?__ %?
277 %idefine __?qnan?__ %?
278 %idefine __?snan?__ %?
280 %idefine __?float8?__ %?
281 %idefine __?float16?__ %?
282 %idefine __?float32?__ %?
283 %idefine __?float64?__ %?
284 %idefine __?float80m?__ %?
285 %idefine __?float80e?__ %?
286 %idefine __?float128l?__ %?
287 %idefine __?float128h?__ %?
289 %idefine __?utf16?__ %?
290 %idefine __?utf16le?__ %?
291 %idefine __?utf16be?__ %?
292 %idefine __?utf32?__ %?
293 %idefine __?utf32le?__ %?
294 %idefine __?utf32be?__ %?
296 %idefine __?ilog2e?__ %?
297 %idefine __?ilog2w?__ %?
298 %idefine __?ilog2f?__ %?
299 %idefine __?ilog2c?__ %?
301 %idefalias __infinity__ __?infinity?__
302 %idefalias __nan__ __?nan?__
303 %idefalias __qnan__ __?qnan?__
304 %idefalias __snan__ __?snan?__
306 %idefalias __float8__ __?float8?__
307 %idefalias __float16__ __?float16?__
308 %idefalias __float32__ __?float32?__
309 %idefalias __float64__ __?float64?__
310 %idefalias __float80m__ __?float80m?__
311 %idefalias __float80e__ __?float80e?__
312 %idefalias __float128l__ __?float128l?__
313 %idefalias __float128h__ __?float128h?__
315 %idefalias __utf16__ __?utf16?__
316 %idefalias __utf16le__ __?utf16le?__
317 %idefalias __utf16be__ __?utf16be?__
318 %idefalias __utf32__ __?utf32?__
319 %idefalias __utf32le__ __?utf32le?__
320 %idefalias __utf32be__ __?utf32be?__
322 %idefalias __ilog2e__ __?ilog2e?__
323 %idefalias __ilog2w__ __?ilog2w?__
324 %idefalias __ilog2f__ __?ilog2f?__
325 %idefalias __ilog2c__ __?ilog2c?__