1 ;; --------------------------------------------------------------------------
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.
7 ;; Redistribution and use in source and binary forms, with or without
8 ;; modification, are permitted provided that the following
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
45 ; The normal standard macros
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]
60 %imacro segment 1+.nolist
61 %define __?SECT?__ [segment %1]
65 %define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 1
66 %imacro sectalign 1+.nolist
68 %define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 0
70 %define __?SECTALIGN_ALIGN_UPDATES_SECTION?__ 1
75 %defalias __SECTALIGN_ALIGN_UPDATES_SECTION__ __?SECTALIGN_ALIGN_UPDATES_SECTION?__
77 %imacro absolute 1+.nolist
78 %define __?SECT?__ [absolute %1]
82 %imacro struc 1-2.nolist 0
84 %define %$strucname %1
86 %$strucname: ; allow definition of `.member' to work sanely
89 %imacro endstruc 0.nolist
90 %{$strucname}_size equ ($-%$strucname)
95 %imacro istruc 1.nolist
97 %define %$strucname %1
101 %imacro at 1-2+.nolist
102 times (%1-%$strucname)-($-%$strucstart) db 0
106 %imacro iend 0.nolist
107 times %{$strucname}_size-($-%$strucstart) db 0
111 %imacro align 1-2+.nolist nop
112 %if __?SECTALIGN_ALIGN_UPDATES_SECTION?__
115 times (((%1) - (($-$$) % (%1))) % (%1)) %2
118 %imacro alignb 1-2+.nolist
119 %if __?SECTALIGN_ALIGN_UPDATES_SECTION?__
125 resb (((%1) - (($-$$) % (%1))) % (%1))
128 times (((%1) - (($-$$) % (%1))) % (%1)) %2
132 %imacro bits 1+.nolist
136 %imacro use16 0.nolist
140 %imacro use32 0.nolist
144 %imacro use64 0.nolist
148 %imacro extern 1-*.nolist
155 %imacro static 1-*.nolist
162 %imacro global 1-*.nolist
169 %imacro required 1-*.nolist
176 %imacro common 1-*.nolist
183 %imacro cpu 1+.nolist
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
201 %define __?FLOAT_DAZ?__ daz
203 %define __?FLOAT_DAZ?__ nodaz
205 %define __?FLOAT_ROUND?__ near
207 %define __?FLOAT_ROUND?__ up
209 %define __?FLOAT_ROUND?__ down
211 %define __?FLOAT_ROUND?__ zero
213 %define __?FLOAT_DAZ?__ nodaz
214 %define __?FLOAT_ROUND?__ near
220 %imacro default 1+.nolist
224 %imacro userel 0.nolist
227 %imacro useabs 0.nolist
230 %imacro usebnd 0.nolist
233 %imacro usenobnd 0.nolist
237 %imacro incbin 1-2+.nolist 0
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?__