Add new copyright headers to the rdoff code
[nasm.git] / standard.mac
blob188c3f8ffa554d8af499177d34de6a9610e5f6b9
1 ;; --------------------------------------------------------------------------
2 ;;   
3 ;;   Copyright 1996-2009 The NASM Authors - All Rights Reserved
4 ;;   See the file AUTHORS included with the NASM distribution for
5 ;;   the specific copyright holders.
6 ;;
7 ;;   This program is free software; you can redistribute it and/or modify
8 ;;   it under the terms of the GNU Lesser General Public License as
9 ;;   published by the Free Software Foundation, Inc.,
10 ;;   51 Franklin St, Fifth Floor, Boston MA 02110-1301, USA; version 2.1,
11 ;;   or, at your option, any later version, incorporated herein by
12 ;;   reference.
14 ;;   Patches submitted to this file are required to be dual licensed
15 ;;   under the LGPL 2.1+ and the 2-clause BSD license:
17 ;;   Copyright 1996-2009 the NASM Authors - All rights reserved.
19 ;;   Redistribution and use in source and binary forms, with or without
20 ;;   modification, are permitted provided that the following
21 ;;   conditions are met:
23 ;;   * Redistributions of source code must retain the above copyright
24 ;;     notice, this list of conditions and the following disclaimer.
25 ;;   * Redistributions in binary form must reproduce the above
26 ;;     copyright notice, this list of conditions and the following
27 ;;     disclaimer in the documentation and/or other materials provided
28 ;;     with the distribution.
29 ;;     
30 ;;     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
31 ;;     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
32 ;;     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33 ;;     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 ;;     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
35 ;;     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 ;;     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 ;;     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 ;;     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 ;;     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
40 ;;     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
41 ;;     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
42 ;;     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 ;; --------------------------------------------------------------------------
46 ; Standard macro set for NASM -*- nasm -*-
48 ; Macros to make NASM ignore some TASM directives before the first include
49 ; directive.
51     %idefine IDEAL
52     %idefine JUMPS
53     %idefine P386
54     %idefine P486
55     %idefine P586
56     %idefine END
58 ; This is a magic token which indicates the end of the TASM macros
59 *END*TASM*MACROS*
61 ; Note that although some user-level forms of directives are defined
62 ; here, not all of them are: the user-level form of a format-specific
63 ; directive should be defined in the module for that directive.
65 ; These three need to be defined, though the actual definitions will
66 ; be constantly updated during preprocessing.
67 %define __FILE__
68 %define __LINE__
69 %define __BITS__
71 %define __SECT__                ; it ought to be defined, even if as nothing
73 %imacro section 1+.nolist
74 %define __SECT__ [section %1]
75           __SECT__
76 %endmacro
77 %imacro segment 1+.nolist
78 %define __SECT__ [segment %1]
79           __SECT__
80 %endmacro
82 %imacro absolute 1+.nolist
83 %define __SECT__ [absolute %1]
84           __SECT__
85 %endmacro
87 %imacro struc 1-2.nolist 0
88 %push
89 %define %$strucname %1
90 [absolute %2]
91 %$strucname:                    ; allow definition of `.member' to work sanely
92 %endmacro
93 %imacro endstruc 0.nolist
94 %{$strucname}_size equ ($-%$strucname)
95 %pop
96 __SECT__
97 %endmacro
99 %imacro istruc 1.nolist
100 %push
101 %define %$strucname %1
102 %$strucstart:
103 %endmacro
104 %imacro at 1-2+.nolist
105           times (%1-%$strucname)-($-%$strucstart) db 0
106           %2
107 %endmacro
108 %imacro iend 0.nolist
109           times %{$strucname}_size-($-%$strucstart) db 0
110 %pop
111 %endmacro
113 %imacro align 1-2+.nolist nop
114           times (((%1) - (($-$$) % (%1))) % (%1)) %2
115 %endmacro
116 %imacro alignb 1-2+.nolist
117           %ifempty %2
118                 resb (((%1) - (($-$$) % (%1))) % (%1))
119           %else
120                 times (((%1) - (($-$$) % (%1))) % (%1)) %2
121           %endif
122 %endmacro
124 %imacro extern 1-*.nolist
125 %rep %0
126 [extern %1]
127 %rotate 1
128 %endrep
129 %endmacro
131 %imacro bits 1+.nolist
132 [bits %1]
133 %endmacro
135 %imacro use16 0.nolist
136 [bits 16]
137 %endmacro
138 %imacro use32 0.nolist
139 [bits 32]
140 %endmacro
141 %imacro use64 0.nolist
142 [bits 64]
143 %endmacro
145 %imacro global 1-*.nolist
146 %rep %0
147 [global %1]
148 %rotate 1
149 %endrep
150 %endmacro
152 %imacro common 1-*.nolist
153 %rep %0
154 [common %1]
155 %rotate 1
156 %endrep
157 %endmacro
159 %imacro cpu 1+.nolist
160 [cpu %1]
161 %endmacro
163 %define __FLOAT_DAZ__ nodaz
164 %define __FLOAT_ROUND__ near
165 ; __FLOAT__ contains the whole floating-point configuration so it can
166 ; be saved and restored
167 %define __FLOAT__ __FLOAT_DAZ__,__FLOAT_ROUND__
168 %imacro float 1-*.nolist
169 %rep %0
170 [float %1]
171 %ifidni %1,daz
172 %define __FLOAT_DAZ__ daz
173 %elifidni %1,nodaz
174 %define __FLOAT_DAZ__ nodaz
175 %elifidni %1,near
176 %define __FLOAT_ROUND__ near
177 %elifidni %1,up
178 %define __FLOAT_ROUND__ up
179 %elifidni %1,down
180 %define __FLOAT_ROUND__ down
181 %elifidni %1,zero
182 %define __FLOAT_ROUND__ zero
183 %elifidni %1,default
184 %define __FLOAT_DAZ__ nodaz
185 %define __FLOAT_ROUND__ near
186 %endif
187 %rotate 1
188 %endrep
189 %endmacro
191 %imacro default 1+.nolist
192 [default %1]
193 %endmacro
195 %imacro incbin 1-2+.nolist 0
196 %push
197 %pathsearch %$dep %1
198 %depend %$dep
199         %? %$dep,%2
200 %pop
201 %endmacro