2 The Netwide Assembler: NASM
3 ===========================
5 --------------------------------------------------------------------------------
6 SciTech MGL Modifications
7 --------------------------------------------------------------------------------
9 All changes can be compiled in and out using the TASM_COMPAT macros,
10 and when compiled without TASM_COMPAT defined we get the exact same
11 binary as the unmodified 0.98 sources.
15 . Added macros to ignore TASM directives before first include
18 . Added extern declaration for tasm_compatible_mode
21 . Added global variable tasm_compatible_mode
22 . Added command line switch for TASM compatible mode (-t)
23 . Changed version command line to reflect when compiled with TASM additions
24 . Added response file processing to allow all arguments on a single
25 line (response file is @resp rather than -@resp for NASM format).
28 . Changes islocal() macro to support TASM style @@local labels.
29 . Added islocalchar() macro to support TASM style @@local labels.
32 . Added support for TASM style memory references (ie: mov [DWORD eax],10
33 rather than the NASM style mov DWORD [eax],10).
36 . Added new directives, %arg, %local, %stacksize to directives table
37 . Added support for TASM style directives without a leading % symbol.
39 --------------------------------------------------------------------------------
40 Integrated a block of changes from Andrew Zabolotny <bit@eltech.ru>:
41 --------------------------------------------------------------------------------
43 -*- A new keyword %xdefine and its case-insensitive counterpart %ixdefine.
44 They work almost the same way as %define and %idefine but expand
45 the definition immediately, not on the invocation. Something like a cross
46 between %define and %assign. The "x" suffix stands for "eXpand", so
47 "xdefine" can be deciphered as "expand-and-define". Thus you can do
53 %xdefine %1 dword [esp+ofs]
57 -*- Changed the place where the expansion of %$name macros are expanded.
58 Now they are converted into ..@ctxnum.name form when detokenizing, so
59 there are no quirks as before when using %$name arguments to macros,
60 in macros etc. For example:
69 Now last line will be expanded into "hello" as expected. This also allows
70 for lots of goodies, a good example are extended "proc" macros included
73 -*- Added a check for "cstk" in smacro_defined() before calling get_ctx() -
74 this allows for things like:
79 to work without warnings even in no context.
81 -*- Added a check for "cstk" in %if*ctx and %elif*ctx directives -
82 this allows to use %ifctx without excessive warnings. If there is
83 no active context, %ifctx goes through "false" branch.
85 -*- Removed "user error: " prefix with %error directive: it just clobbers the
86 output and has absolutely no functionality. Besides, this allows to write
87 macros that does not differ from built-in functions in any way.
89 -*- Added expansion of string that is output by %error directive. Now you
92 %define hello(x) Hello, x!
95 %error "hello(%$name)"
97 Same happened with %include directive.
99 -*- Now all directives that expect an identifier will try to expand and
100 concatenate everything without whitespaces in between before usage.
101 For example, with "unfixed" nasm the commands
104 %define __%$abc goodbye
107 would produce "incorrect" output: last line will expand to
111 Not quite what you expected, eh? :-) The answer is that preprocessor
112 treats the %define construct as if it would be
114 %define __ %$abc goodbye
116 (note the white space between __ and %$abc). After my "fix" it
117 will "correctly" expand into
121 as expected. Note that I use quotes around words "correct", "incorrect"
122 etc because this is rather a feature not a bug; however current behaviour
123 is more logical (and allows more advanced macro usage :-).
125 Same change was applied to:
126 %push,%macro,%imacro,%define,%idefine,%xdefine,%ixdefine,
127 %assign,%iassign,%undef
129 -*- A new directive [WARNING {+|-}warning-id] have been added. It works only
130 if the assembly phase is enabled (i.e. it doesn't work with nasm -e).
132 -*- A new warning type: macro-selfref. By default this warning is disabled;
133 when enabled NASM warns when a macro self-references itself; for example
134 the following source:
136 [WARNING macro-selfref]
147 will produce a warning, but if we remove the first line we won't see it
148 anymore (which is The Right Thing To Do {tm} IMHO since C preprocessor
149 eats such constructs without warnings at all).
151 -*- Added a "error" routine to preprocessor which always will set ERR_PASS1
152 bit in severity_code. This removes annoying repeated errors on first
153 and second passes from preprocessor.
155 -*- Added the %+ operator in single-line macros for concatenating two
156 identifiers. Usage example:
158 %define _myfunc _otherfunc
159 %define cextern(x) _ %+ x
162 After first expansion, third line will become "_myfunc". After this
163 expansion is performed again so it becomes "_otherunc".
165 -*- Now if preprocessor is in a non-emmitting state, no warning or error
166 will be emmitted. Example:
171 put anything you want between these two brackets,
172 even macro-parameter references %1 or local labels %$zz
173 or macro-local labels %%zz - no warning will be emmitted.
176 -*- Context-local variables on expansion as a last resort are looked up
177 in outer contexts. For example, the following piece:
187 will expand correctly the fourth line to [esp]; if we'll define another
188 %$a inside the "inner" context, it will take precedence over outer
189 definition. However, this modification has been applied only to
190 expand_smacro and not to smacro_define: as a consequence expansion
191 looks in outer contexts, but %ifdef won't look in outer contexts.
193 This behaviour is needed because we don't want nested contexts to
194 act on already defined local macros. Example:
196 %define %$arg1 [esp+4]
202 In this example the "if" mmacro enters into the "if" context, so %$arg1
203 is not valid anymore inside "if". Of course it could be worked around
204 by using explicitely %$$arg1 but this is ugly IMHO.
206 -*- Fixed memory leak in %undef. The origline wasn't freed before
209 -*- Fixed trap in preprocessor when line expanded to empty set of tokens.
210 This happens, for example, in the following case: