NASM 0.98-j4
[nasm/avx512.git] / changes.asm
blob7b9dd491b48eb627a7e2b017d85a4d90c3fc1533
1 ;This file demonstrates many of the differences between NASM version X and NASM
2 ;version 0.97
4 ; changes.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 changes.asm -l changes.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 changes.asm -l changes.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 changes.asm -l changes.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 changes.asm -l changes.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"
53 times 2 a16 call next
54 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
61 prior:
62 .1:
63 here: jmp .1
64 .1:
66 ;-----------------------------------------------------------------------------
67 ; Bug fixed by John in assemble()
69 ; Strings used in dq and dt were not zero filled correctly
71 dq 'b'
74 ;-----------------------------------------------------------------------------
75 ; Bug fixed by Simon in isn_names[]
77 ; Was not recognised as an instruction
79 int01
81 ;-----------------------------------------------------------------------------
82 ; Bug fixed by Jim Hague in ???
84 ; Forward references were instruction level rather than per operand
86 shr word [forwardref],1
87 forwardref:
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).
95 %macro xxx 1
96 %1: nop
97 %{1}x: jmp %1x
98 %endmacro
99 xxx yyy
101 %ifdef oldmsg
102 ;***************************************************************
104 ; The following examples will generate error messages in 0.97 and will generate
105 ; correct output in the new version.
107 ;-----------------------------------------------------------------------------
108 ; Bug fixed by Simon in isns.dat
110 ; The optional "near" was not permitted on JMP and CALL
112 jmp near here
114 ;-----------------------------------------------------------------------------
115 ; Feature added by Simon in stdscan()
117 ; You can now use the numeric value of strings in %assign
119 %assign xxx 'ABCD'
120 dd xxx
122 ;-----------------------------------------------------------------------------
123 ; Feature added by John in add_vectors()
125 ; Stranger address expressions are now supported as long as they resolve to
126 ; something valid.
128 mov ax, [eax + ebx + ecx - eax]
130 ;-----------------------------------------------------------------------------
131 ; Bug fixed by Simon in ???
133 ; The EQU directive affected local labels in a way that was inconsistent
134 ; between passes
136 .local:
137 neither equ $
138 jmp .local
140 ;-----------------------------------------------------------------------------
141 ; Feature added by Jules in parse_line
143 ; You can override a size specifier
145 %define arg1 dword [bp+4]
146 cmp word arg1, 2
148 ;-----------------------------------------------------------------------------
149 ; Bug fixed by John in preproc.c
151 ; You could not use a label on the same line with a macro invocation, if the
152 ; macro definition began with a preprocessor directive.
154 struc mytype
155 .long resd 1
156 endstruc
158 lbl istruc mytype
159 at mytype.long, dd 'ABCD'
160 iend
162 ;-----------------------------------------------------------------------------
163 ; Warning removed by John in preproc.c
165 ; In order to allow macros that extend the definition of instructions, I
166 ; disabled the warning on a multi-line macro referencing itself.
168 %endif ;NASM 0.97 doesn't handle %0 etc. inside false %if
169 %macro push 1-* ;
170 %rep %0 ;
171 push %1 ;
172 %rotate 1 ;
173 %endrep ;
174 %endmacro ;
175 %ifdef oldmsg ;
177 push ax,bx
179 ;-----------------------------------------------------------------------------
180 ; Warning removed by John in preproc.c
182 ; To support other types of macros that extend the definition of instructions,
183 ; I disabled the warning on a multi-line macro called with the wrong number of
184 ; parameters. PUSH and POP can be extended equally well by either method, but
185 ; other intruction extensions may need one method or the other, so I made both
186 ; work.
188 ; Note that neither of these warnings was really needed, because a later stage
189 ; of NASM would almost always give an adequate error message if the macro use
190 ; really was wrong.
192 %endif
193 %macro pop 2-*
194 %rep %0
195 pop %1
196 %rotate 1
197 %endrep
198 %endmacro
199 %ifdef oldmsg
201 pop ax,bx
202 %endif
205 %ifdef newmsg ;***************************************************************
207 ;-----------------------------------------------------------------------------
208 ; Bug fixed by John in parse_line() (and other routines)
210 ; This invalid code used to assemble without errors
212 myself equ myself+1
213 jmp myself
215 ;-----------------------------------------------------------------------------
216 ; Change made by John in preproc.c
218 ; In 0.97, an id that appears as a label on a macro invocation was always
219 ; prepended to the first line of the macro expansion. That caused several
220 ; bugs, but also could be used in tricks like the arg macro in c16.mac and
221 ; c32.mac.
223 ; In version X, an id that appears as a label on a macro invocation will
224 ; normally be defined as a label for the address at which the macro is
225 ; invoked, regardless of whether the first line of the macro expansion is
226 ; something that can take a label. The new token %00 may be used for any
227 ; of the situations in which the old prepend behavior was doing something
228 ; tricky but useful. %00 can also be used more than once and in places
229 ; other than the start of the expansion.
231 %endif
232 %assign arg_off 0
234 %imacro arg 0-1 2 ;arg defined the old way
235 equ arg_off
236 %assign arg_off %1+arg_off
237 %endmacro
239 %ifdef newmsg
240 arg_example arg
241 %endif
243 %imacro arg2 0-1 2 ;arg defined the new way
244 %00 equ arg_off
245 %assign arg_off %1+arg_off
246 %endmacro
248 %ifdef oldmsg
249 arg_example2 arg2
251 ;-----------------------------------------------------------------------------
252 ; Change made by Jules and John in INSNS.DAT
254 ; Various instruction in which the size of an immediate is built-in to the
255 ; instruction set, now allow you to redundantly specify that size as long
256 ; as you specify it correctly
258 AAD byte 5
259 AAM byte 5
260 BT bx, byte 3
261 BTC cx, byte 4
262 BTR dx, byte 5
263 BTS si, byte 6
264 IN eax, byte 0x40
265 INT byte 21h
266 OUT byte 70h, ax
267 RET word 2
268 RETN word 2
269 RETF word 4
271 ; note "ENTER" has not been changed yet.
273 %endif
275 %ifdef oldcrash ;*************************************************************
277 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___
279 ;-----------------------------------------------------------------------------
280 ; Bug fixed by John in preproc.c
282 ; Builds of NASM that prohibit dereferencing a NULL pointer used to crash if a
283 ; macro that started with a blank line was invoked with a label
285 %macro empty_macro 0
287 %endm
289 emlabel empty_macro
290 jmp emlabel
292 %endif