ofmt: Implement null_segalign stubs
[nasm.git] / standard.mac
bloba7a52dbf89e29292d31ae530009e09e6106374c3
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 ;;   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.
17 ;;     
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 before the first include
37 ; directive.
39     %idefine IDEAL
40     %idefine JUMPS
41     %idefine P386
42     %idefine P486
43     %idefine P586
44     %idefine END
46 ; This is a magic token which indicates the end of the TASM macros
47 *END*TASM*MACROS*
49 ; Note that although some user-level forms of directives are defined
50 ; here, not all of them are: the user-level form of a format-specific
51 ; directive should be defined in the module for that directive.
53 ; These three need to be defined, though the actual definitions will
54 ; be constantly updated during preprocessing.
55 %define __FILE__
56 %define __LINE__
57 %define __BITS__
59 %define __SECT__                ; it ought to be defined, even if as nothing
61 %imacro section 1+.nolist
62 %define __SECT__ [section %1]
63           __SECT__
64 %endmacro
65 %imacro segment 1+.nolist
66 %define __SECT__ [segment %1]
67           __SECT__
68 %endmacro
69 %imacro segalign 1+.nolist
70 %define __SECT__ [segalign %1]
71           __SECT__
72 %endmacro
74 %imacro absolute 1+.nolist
75 %define __SECT__ [absolute %1]
76           __SECT__
77 %endmacro
79 %imacro struc 1-2.nolist 0
80 %push
81 %define %$strucname %1
82 [absolute %2]
83 %$strucname:                    ; allow definition of `.member' to work sanely
84 %endmacro
85 %imacro endstruc 0.nolist
86 %{$strucname}_size equ ($-%$strucname)
87 %pop
88 __SECT__
89 %endmacro
91 %imacro istruc 1.nolist
92 %push
93 %define %$strucname %1
94 %$strucstart:
95 %endmacro
96 %imacro at 1-2+.nolist
97           times (%1-%$strucname)-($-%$strucstart) db 0
98           %2
99 %endmacro
100 %imacro iend 0.nolist
101           times %{$strucname}_size-($-%$strucstart) db 0
102 %pop
103 %endmacro
105 %imacro align 1-2+.nolist nop
106           times (((%1) - (($-$$) % (%1))) % (%1)) %2
107 %endmacro
108 %imacro alignb 1-2+.nolist
109           %ifempty %2
110                 resb (((%1) - (($-$$) % (%1))) % (%1))
111           %else
112                 times (((%1) - (($-$$) % (%1))) % (%1)) %2
113           %endif
114 %endmacro
116 %imacro extern 1-*.nolist
117 %rep %0
118 [extern %1]
119 %rotate 1
120 %endrep
121 %endmacro
123 %imacro bits 1+.nolist
124 [bits %1]
125 %endmacro
127 %imacro use16 0.nolist
128 [bits 16]
129 %endmacro
130 %imacro use32 0.nolist
131 [bits 32]
132 %endmacro
133 %imacro use64 0.nolist
134 [bits 64]
135 %endmacro
137 %imacro global 1-*.nolist
138 %rep %0
139 [global %1]
140 %rotate 1
141 %endrep
142 %endmacro
144 %imacro common 1-*.nolist
145 %rep %0
146 [common %1]
147 %rotate 1
148 %endrep
149 %endmacro
151 %imacro cpu 1+.nolist
152 [cpu %1]
153 %endmacro
155 %define __FLOAT_DAZ__ nodaz
156 %define __FLOAT_ROUND__ near
157 ; __FLOAT__ contains the whole floating-point configuration so it can
158 ; be saved and restored
159 %define __FLOAT__ __FLOAT_DAZ__,__FLOAT_ROUND__
160 %imacro float 1-*.nolist
161 %rep %0
162 [float %1]
163 %ifidni %1,daz
164 %define __FLOAT_DAZ__ daz
165 %elifidni %1,nodaz
166 %define __FLOAT_DAZ__ nodaz
167 %elifidni %1,near
168 %define __FLOAT_ROUND__ near
169 %elifidni %1,up
170 %define __FLOAT_ROUND__ up
171 %elifidni %1,down
172 %define __FLOAT_ROUND__ down
173 %elifidni %1,zero
174 %define __FLOAT_ROUND__ zero
175 %elifidni %1,default
176 %define __FLOAT_DAZ__ nodaz
177 %define __FLOAT_ROUND__ near
178 %endif
179 %rotate 1
180 %endrep
181 %endmacro
183 %imacro default 1+.nolist
184 [default %1]
185 %endmacro
187 %imacro incbin 1-2+.nolist 0
188 %push
189 %pathsearch %$dep %1
190 %depend %$dep
191         %? %$dep,%2
192 %pop
193 %endmacro