1 ;This file demonstrates many of the differences between NASM version X and NASM
4 ; changed.asm is copyright (C) 1998 John S. Fine
6 ; It may be redistributed under the same conditions as NASM as described in
7 ; Licence file in the NASM archive
8 ;_________________________________
10 ; nasm changed.asm -l changed.lst
12 ; When assembled without any -d switches, it includes examples which:
13 ; Work correctly in version X
14 ; and Work incorrectly and/or display warnings in version 0.97
15 ; and Do not prevent the generation of output in version 0.97
17 ; Not all the differences can be seen in the .lst file. I suggest that you use
18 ; "ndisasm changes" to examine the code actually generated.
19 ;_________________________________
21 ; nasm changed.asm -l changed.lst -doldmsg
23 ; When assembled with -doldmsg, it adds examples which:
24 ; Work correctly in version X
25 ; and Generate error messages in version 0.97 and do not generate output
26 ;_________________________________
28 ; nasm changed.asm -l changed.lst -doldcrash
30 ; When assembled with -doldcrash, it adds examples which:
31 ; Work correctly in version X
32 ; and Cause NASM to crash in version 0.97
33 ;_________________________________
35 ; nasm changed.asm -l changed.lst -dnewmsg
37 ; When assembled with -dnewmsg, it adds examples which:
38 ; Generate error messages in version X
39 ; and Generate wrong output without warning or error message in version 0.97
40 ;-----------------------------------------------------------------------------
42 ; Please note that I have reported the name of the person who made the
43 ; correction based on very limited information. In several cases, I am sure I
44 ; will identify the wrong author. Please send me any corrections; I don't
45 ; intend to insult or exclude anyone.
47 ;-----------------------------------------------------------------------------
48 ; Bug fixed by Simon in assemble()
50 ; The following generated "call next" / "call next-1" instead of
51 ; two copies of "call next"
56 ;-----------------------------------------------------------------------------
57 ; Bug fixed by John in parse_line() (and other routines)
59 ; This used to jmp to prior.1, when it should be here.1
66 ;-----------------------------------------------------------------------------
67 ; Bug fixed by John in assemble()
69 ; Strings used in dq and dt were not zero filled correctly
74 ;-----------------------------------------------------------------------------
75 ; Bug fixed by Simon in isn_names[]
77 ; Was not recognised as an instruction
79 int01
; Instead of INT1
81 ;-----------------------------------------------------------------------------
82 ; Bug fixed by Jim Hague in ???
84 ; Forward references were instruction level rather than per operand
86 shr word [forwardref
],1
89 ;-----------------------------------------------------------------------------
90 ; Bug fixed by John in preproc.c
92 ; It used to silently discard id characters appended to a multi-line
93 ; macro parameter (such as the x in %1x below).
101 ;-----------------------------------------------------------------------------
102 ; Bug added by John in preproc.c 0.98-J4, removed by John in 0.98-J5
104 ; Tested here to make sure it stays removed
115 ;***************************************************************
117 ; The following examples will generate error messages in 0.97 and will generate
118 ; correct output in the new version.
120 ;-----------------------------------------------------------------------------
121 ; Bug fixed by Simon in isns.dat
123 ; The optional "near" was not permitted on JMP and CALL
127 ;-----------------------------------------------------------------------------
128 ; Feature added by Simon in stdscan()
130 ; You can now use the numeric value of strings in %assign
135 ;-----------------------------------------------------------------------------
136 ; Feature added by John in add_vectors()
138 ; Stranger address expressions are now supported as long as they resolve to
141 mov ax, [eax + ebx + ecx - eax]
143 ;-----------------------------------------------------------------------------
144 ; Bug fixed by Simon in ???
146 ; The EQU directive affected local labels in a way that was inconsistent
153 ;-----------------------------------------------------------------------------
154 ; Feature added by Jules in parse_line
156 ; You can override a size specifier
158 %define arg1
dword [bp+4]
161 ;-----------------------------------------------------------------------------
162 ; Bug fixed by John in preproc.c
164 ; You could not use a label on the same line with a macro invocation, if the
165 ; macro definition began with a preprocessor directive.
172 at mytype.long
, dd 'ABCD'
175 ;-----------------------------------------------------------------------------
176 ; Warning removed by John in preproc.c
178 ; In order to allow macros that extend the definition of instructions, I
179 ; disabled the warning on a multi-line macro referencing itself.
181 %endif
;NASM 0.97 doesn't handle %0 etc. inside false %if
192 ;-----------------------------------------------------------------------------
193 ; Warning removed by John in preproc.c
195 ; To support other types of macros that extend the definition of instructions,
196 ; I disabled the warning on a multi-line macro called with the wrong number of
197 ; parameters. PUSH and POP can be extended equally well by either method, but
198 ; other intruction extensions may need one method or the other, so I made both
201 ; Note that neither of these warnings was really needed, because a later stage
202 ; of NASM would almost always give an adequate error message if the macro use
218 %ifdef newmsg
;***************************************************************
220 ;-----------------------------------------------------------------------------
221 ; Bug fixed by John in parse_line() (and other routines)
223 ; This invalid code used to assemble without errors
228 ;-----------------------------------------------------------------------------
229 ; Change made by John in preproc.c
231 ; In 0.97, an id that appears as a label on a macro invocation was always
232 ; prepended to the first line of the macro expansion. That caused several
233 ; bugs, but also could be used in tricks like the arg macro in c16.mac and
236 ; In version X, an id that appears as a label on a macro invocation will
237 ; normally be defined as a label for the address at which the macro is
238 ; invoked, regardless of whether the first line of the macro expansion is
239 ; something that can take a label. The new token %00 may be used for any
240 ; of the situations in which the old prepend behavior was doing something
241 ; tricky but useful. %00 can also be used more than once and in places
242 ; other than the start of the expansion.
247 %imacro arg
0-1 2 ;arg defined the old way
249 %assign arg_off
%1+arg_off
256 %imacro arg2
0-1 2 ;arg defined the new way
258 %assign arg_off
%1+arg_off
264 ;-----------------------------------------------------------------------------
265 ; Change made by Jules and John in INSNS.DAT
267 ; Various instruction in which the size of an immediate is built-in to the
268 ; instruction set, now allow you to redundantly specify that size as long
269 ; as you specify it correctly
284 ; note "ENTER" has not been changed yet.
286 ;-----------------------------------------------------------------------------
287 ; Enhancement by hpa in insns.dat et al
289 ; Simplified adding new instructions, and added some missing instructions
291 int03
; Instead of INT3
292 ud1
; No documented mnemonic for this one
299 fxrstor
[es:ebx+esi*4+0x3000]
301 ;-----------------------------------------------------------------------------
302 ; Enhancement by hpa in insns.dat et al
304 ; Actually make SSE work, and use the -p option to ndisasm to select
305 ; one of several aliased opcodes
307 sqrtps xmm0
,[ebx+10] ; SSE opcode
308 paddsiw mm0
,[ebx+10] ; Cyrix opcode with the same byte seq.
310 ;-----------------------------------------------------------------------------
311 ; Enhancement by hpa in preproc.c
313 ; Support %undef to remoce a single-line macro
317 %error
"TEST_ME not defined after %define"
322 %error
"TEST_ME defined after %undef"
325 ;-----------------------------------------------------------------------------
326 ; Bug fix by hpa in insns.dat
328 ; PSHUFW and PINSRW weren't handling the implicit sizes correctly; all of
329 ; the entries below are (or should be) legal
333 pshufw mm7
,[0+edi*8],1
335 pshufw mm2
, mm1
, byte 3
336 pshufw mm3
,[ebx],byte 2
337 pshufw mm7
,[0+edi*8],byte 1
340 pshufw mm3
, qword [ebx], 2
341 pshufw mm7
, qword [0+edi*8], 1
343 pshufw mm2
, mm1
, byte 3
344 pshufw mm3
, qword [ebx], byte 2
345 pshufw mm7
, qword [0+edi*8], byte 1
348 pinsrw mm1
, word [esi], 1
349 pinsrw mm1
, [esi], byte 1
350 pinsrw mm1
, word [esi], byte 1
355 %ifdef oldcrash
;*************************************************************
357 This_label_is_256_characters_long__There_used_to_be_a_bug_in_stdscan_which_made_it_crash_when_it_did_a_keyword_search_on_any_label_longer_than_255_characters__Now_anything_longer_than_MAX_KEYWORD_is_always_a_symbol__It_will_not_even_try_a_keyword_search___
359 ;-----------------------------------------------------------------------------
360 ; Bug fixed by John in preproc.c
362 ; Builds of NASM that prohibit dereferencing a NULL pointer used to crash if a
363 ; macro that started with a blank line was invoked with a label
372 ;-----------------------------------------------------------------------------
373 ; Enhancement by Conan Brink in preproc.c
375 ; Allow %rep to be nested