coff: Use predefined macro in common section flags
[nasm.git] / standard.mac
blob32a75a8cf76117463a460346baf4cabd1ae8fbb3
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 sectalign 1.nolist
70         [sectalign %1]
71 %endmacro
73 %imacro absolute 1+.nolist
74 %define __SECT__ [absolute %1]
75           __SECT__
76 %endmacro
78 %imacro struc 1-2.nolist 0
79 %push
80 %define %$strucname %1
81 [absolute %2]
82 %$strucname:                    ; allow definition of `.member' to work sanely
83 %endmacro
84 %imacro endstruc 0.nolist
85 %{$strucname}_size equ ($-%$strucname)
86 %pop
87 __SECT__
88 %endmacro
90 %imacro istruc 1.nolist
91 %push
92 %define %$strucname %1
93 %$strucstart:
94 %endmacro
95 %imacro at 1-2+.nolist
96           times (%1-%$strucname)-($-%$strucstart) db 0
97           %2
98 %endmacro
99 %imacro iend 0.nolist
100           times %{$strucname}_size-($-%$strucstart) db 0
101 %pop
102 %endmacro
104 %imacro align 1-2+.nolist nop
105           times (((%1) - (($-$$) % (%1))) % (%1)) %2
106 %endmacro
107 %imacro alignb 1-2+.nolist
108           %ifempty %2
109                 resb (((%1) - (($-$$) % (%1))) % (%1))
110           %else
111                 times (((%1) - (($-$$) % (%1))) % (%1)) %2
112           %endif
113 %endmacro
115 %imacro extern 1-*.nolist
116 %rep %0
117 [extern %1]
118 %rotate 1
119 %endrep
120 %endmacro
122 %imacro bits 1+.nolist
123 [bits %1]
124 %endmacro
126 %imacro use16 0.nolist
127 [bits 16]
128 %endmacro
129 %imacro use32 0.nolist
130 [bits 32]
131 %endmacro
132 %imacro use64 0.nolist
133 [bits 64]
134 %endmacro
136 %imacro global 1-*.nolist
137 %rep %0
138 [global %1]
139 %rotate 1
140 %endrep
141 %endmacro
143 %imacro common 1-*.nolist
144 %rep %0
145 [common %1]
146 %rotate 1
147 %endrep
148 %endmacro
150 %imacro cpu 1+.nolist
151 [cpu %1]
152 %endmacro
154 %define __FLOAT_DAZ__ nodaz
155 %define __FLOAT_ROUND__ near
156 ; __FLOAT__ contains the whole floating-point configuration so it can
157 ; be saved and restored
158 %define __FLOAT__ __FLOAT_DAZ__,__FLOAT_ROUND__
159 %imacro float 1-*.nolist
160 %rep %0
161 [float %1]
162 %ifidni %1,daz
163 %define __FLOAT_DAZ__ daz
164 %elifidni %1,nodaz
165 %define __FLOAT_DAZ__ nodaz
166 %elifidni %1,near
167 %define __FLOAT_ROUND__ near
168 %elifidni %1,up
169 %define __FLOAT_ROUND__ up
170 %elifidni %1,down
171 %define __FLOAT_ROUND__ down
172 %elifidni %1,zero
173 %define __FLOAT_ROUND__ zero
174 %elifidni %1,default
175 %define __FLOAT_DAZ__ nodaz
176 %define __FLOAT_ROUND__ near
177 %endif
178 %rotate 1
179 %endrep
180 %endmacro
182 %imacro default 1+.nolist
183 [default %1]
184 %endmacro
186 %imacro incbin 1-2+.nolist 0
187 %push
188 %pathsearch %$dep %1
189 %depend %$dep
190         %? %$dep,%2
191 %pop
192 %endmacro