-;This file demonstrates many of the differences between NASM version X and NASM\r
-;version 0.97\r
-;\r
-; changes.asm is copyright (C) 1998 John S. Fine\r
-;\r
-; It may be redistributed under the same conditions as NASM as described in\r
-; Licence file in the NASM archive\r
-;_________________________________\r
-;\r
-; nasm changes.asm -l changes.lst\r
-;\r
-; When assembled without any -d switches, it includes examples which:\r
-; Work correctly in version X\r
-; and Work incorrectly and/or display warnings in version 0.97\r
-; and Do not prevent the generation of output in version 0.97\r
-;\r
-; Not all the differences can be seen in the .lst file. I suggest that you use\r
-; "ndisasm changes" to examine the code actually generated.\r
-;_________________________________\r
-;\r
-; nasm changes.asm -l changes.lst -doldmsg\r
-;\r
-; When assembled with -doldmsg, it adds examples which:\r
-; Work correctly in version X\r
-; and Generate error messages in version 0.97 and do not generate output\r
-;_________________________________\r
-;\r
-; nasm changes.asm -l changes.lst -doldcrash\r
-;\r
-; When assembled with -doldcrash, it adds examples which:\r
-; Work correctly in version X\r
-; and Cause NASM to crash in version 0.97\r
-;_________________________________\r
-;\r
-; nasm changes.asm -l changes.lst -dnewmsg\r
-;\r
-; When assembled with -dnewmsg, it adds examples which:\r
-; Generate error messages in version X\r
-; and Generate wrong output without warning or error message in version 0.97\r
-;-----------------------------------------------------------------------------\r
-\r
-; Please note that I have reported the name of the person who made the\r
-; correction based on very limited information. In several cases, I am sure I\r
-; will identify the wrong author. Please send me any corrections; I don't\r
-; intend to insult or exclude anyone.\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by Simon in assemble()\r
-;\r
-; The following generated "call next" / "call next-1" instead of\r
-; two copies of "call next"\r
-;\r
- times 2 a16 call next\r
-next:\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by John in parse_line() (and other routines)\r
-;\r
-; This used to jmp to prior.1, when it should be here.1\r
-;\r
-prior:\r
-.1:\r
-here: jmp .1\r
-.1:\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by John in assemble()\r
-;\r
-; Strings used in dq and dt were not zero filled correctly\r
-;\r
- dq 'b'\r
-\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by Simon in isn_names[]\r
-;\r
-; Was not recognised as an instruction\r
-;\r
- int01\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by Jim Hague in ???\r
-;\r
-; Forward references were instruction level rather than per operand\r
-;\r
- shr word [forwardref],1\r
-forwardref:\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by John in preproc.c\r
-;\r
-; It used to silently discard id characters appended to a multi-line\r
-; macro parameter (such as the x in %1x below).\r
-;\r
-%macro xxx 1\r
-%1: nop\r
-%{1}x: jmp %1x\r
-%endmacro\r
-xxx yyy\r
-\r
-%ifdef oldmsg\r
-;***************************************************************\r
-;\r
-; The following examples will generate error messages in 0.97 and will generate\r
-; correct output in the new version.\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by Simon in isns.dat\r
-;\r
-; The optional "near" was not permitted on JMP and CALL\r
-;\r
- jmp near here\r
-\r
-;-----------------------------------------------------------------------------\r
-; Feature added by Simon in stdscan()\r
-;\r
-; You can now use the numeric value of strings in %assign\r
-;\r
-%assign xxx 'ABCD'\r
- dd xxx\r
-\r
-;-----------------------------------------------------------------------------\r
-; Feature added by John in add_vectors()\r
-;\r
-; Stranger address expressions are now supported as long as they resolve to\r
-; something valid.\r
-;\r
- mov ax, [eax + ebx + ecx - eax]\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by Simon in ???\r
-;\r
-; The EQU directive affected local labels in a way that was inconsistent\r
-; between passes\r
-;\r
-.local:\r
-neither equ $\r
- jmp .local\r
-\r
-;-----------------------------------------------------------------------------\r
-; Feature added by Jules in parse_line\r
-;\r
-; You can override a size specifier\r
-;\r
-%define arg1 dword [bp+4]\r
- cmp word arg1, 2\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by John in preproc.c\r
-;\r
-; You could not use a label on the same line with a macro invocation, if the\r
-; macro definition began with a preprocessor directive.\r
-;\r
- struc mytype\r
-.long resd 1\r
- endstruc\r
-\r
-lbl istruc mytype\r
- at mytype.long, dd 'ABCD'\r
- iend\r
-\r
-;-----------------------------------------------------------------------------\r
-; Warning removed by John in preproc.c\r
-;\r
-; In order to allow macros that extend the definition of instructions, I\r
-; disabled the warning on a multi-line macro referencing itself.\r
-;\r
-%endif ;NASM 0.97 doesn't handle %0 etc. inside false %if\r
-%macro push 1-* ;\r
-%rep %0 ;\r
-push %1 ;\r
-%rotate 1 ;\r
-%endrep ;\r
-%endmacro ;\r
-%ifdef oldmsg ;\r
-\r
- push ax,bx\r
-\r
-;-----------------------------------------------------------------------------\r
-; Warning removed by John in preproc.c\r
-;\r
-; To support other types of macros that extend the definition of instructions,\r
-; I disabled the warning on a multi-line macro called with the wrong number of\r
-; parameters. PUSH and POP can be extended equally well by either method, but\r
-; other intruction extensions may need one method or the other, so I made both\r
-; work.\r
-;\r
-; Note that neither of these warnings was really needed, because a later stage\r
-; of NASM would almost always give an adequate error message if the macro use\r
-; really was wrong.\r
-;\r
-%endif\r
-%macro pop 2-*\r
-%rep %0\r
-pop %1\r
-%rotate 1\r
-%endrep\r
-%endmacro\r
-%ifdef oldmsg\r
-\r
- pop ax,bx\r
-%endif\r
-\r
-\r
-%ifdef newmsg ;***************************************************************\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by John in parse_line() (and other routines)\r
-;\r
-; This invalid code used to assemble without errors\r
-;\r
-myself equ myself+1\r
- jmp myself\r
-\r
-;-----------------------------------------------------------------------------\r
-; Change made by John in preproc.c\r
-;\r
-; In 0.97, an id that appears as a label on a macro invocation was always\r
-; prepended to the first line of the macro expansion. That caused several\r
-; bugs, but also could be used in tricks like the arg macro in c16.mac and\r
-; c32.mac.\r
-;\r
-; In version X, an id that appears as a label on a macro invocation will\r
-; normally be defined as a label for the address at which the macro is\r
-; invoked, regardless of whether the first line of the macro expansion is\r
-; something that can take a label. The new token %00 may be used for any\r
-; of the situations in which the old prepend behavior was doing something\r
-; tricky but useful. %00 can also be used more than once and in places\r
-; other than the start of the expansion.\r
-;\r
-%endif\r
-%assign arg_off 0\r
-\r
-%imacro arg 0-1 2 ;arg defined the old way\r
- equ arg_off\r
-%assign arg_off %1+arg_off\r
-%endmacro\r
-\r
-%ifdef newmsg\r
-arg_example arg\r
-%endif\r
-\r
-%imacro arg2 0-1 2 ;arg defined the new way\r
-%00 equ arg_off\r
-%assign arg_off %1+arg_off\r
-%endmacro\r
-\r
-%ifdef oldmsg\r
-arg_example2 arg2\r
-\r
-;-----------------------------------------------------------------------------\r
-; Change made by Jules and John in INSNS.DAT\r
-;\r
-; Various instruction in which the size of an immediate is built-in to the\r
-; instruction set, now allow you to redundantly specify that size as long\r
-; as you specify it correctly\r
-;\r
- AAD byte 5\r
- AAM byte 5\r
- BT bx, byte 3\r
- BTC cx, byte 4\r
- BTR dx, byte 5\r
- BTS si, byte 6\r
- IN eax, byte 0x40\r
- INT byte 21h\r
- OUT byte 70h, ax\r
- RET word 2\r
- RETN word 2\r
- RETF word 4\r
-\r
-; note "ENTER" has not been changed yet.\r
- \r
-%endif\r
-\r
-%ifdef oldcrash ;*************************************************************\r
-\r
-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___\r
-\r
-;-----------------------------------------------------------------------------\r
-; Bug fixed by John in preproc.c\r
-;\r
-; Builds of NASM that prohibit dereferencing a NULL pointer used to crash if a\r
-; macro that started with a blank line was invoked with a label\r
-;\r
-%macro empty_macro 0\r
-\r
-%endm\r
-\r
-emlabel empty_macro\r
- jmp emlabel\r
-\r
-%endif\r
+;This file demonstrates many of the differences between NASM version X and NASM
+;version 0.97
+;
+; changes.asm is copyright (C) 1998 John S. Fine
+;
+; It may be redistributed under the same conditions as NASM as described in
+; Licence file in the NASM archive
+;_________________________________
+;
+; nasm changes.asm -l changes.lst
+;
+; When assembled without any -d switches, it includes examples which:
+; Work correctly in version X
+; and Work incorrectly and/or display warnings in version 0.97
+; and Do not prevent the generation of output in version 0.97
+;
+; Not all the differences can be seen in the .lst file. I suggest that you use
+; "ndisasm changes" to examine the code actually generated.
+;_________________________________
+;
+; nasm changes.asm -l changes.lst -doldmsg
+;
+; When assembled with -doldmsg, it adds examples which:
+; Work correctly in version X
+; and Generate error messages in version 0.97 and do not generate output
+;_________________________________
+;
+; nasm changes.asm -l changes.lst -doldcrash
+;
+; When assembled with -doldcrash, it adds examples which:
+; Work correctly in version X
+; and Cause NASM to crash in version 0.97
+;_________________________________
+;
+; nasm changes.asm -l changes.lst -dnewmsg
+;
+; When assembled with -dnewmsg, it adds examples which:
+; Generate error messages in version X
+; and Generate wrong output without warning or error message in version 0.97
+;-----------------------------------------------------------------------------
+
+; Please note that I have reported the name of the person who made the
+; correction based on very limited information. In several cases, I am sure I
+; will identify the wrong author. Please send me any corrections; I don't
+; intend to insult or exclude anyone.
+
+;-----------------------------------------------------------------------------
+; Bug fixed by Simon in assemble()
+;
+; The following generated "call next" / "call next-1" instead of
+; two copies of "call next"
+;
+ times 2 a16 call next
+next:
+
+;-----------------------------------------------------------------------------
+; Bug fixed by John in parse_line() (and other routines)
+;
+; This used to jmp to prior.1, when it should be here.1
+;
+prior:
+.1:
+here: jmp .1
+.1:
+
+;-----------------------------------------------------------------------------
+; Bug fixed by John in assemble()
+;
+; Strings used in dq and dt were not zero filled correctly
+;
+ dq 'b'
+
+
+;-----------------------------------------------------------------------------
+; Bug fixed by Simon in isn_names[]
+;
+; Was not recognised as an instruction
+;
+ int01 ; Instead of INT1
+
+;-----------------------------------------------------------------------------
+; Bug fixed by Jim Hague in ???
+;
+; Forward references were instruction level rather than per operand
+;
+ shr word [forwardref],1
+forwardref:
+
+;-----------------------------------------------------------------------------
+; Bug fixed by John in preproc.c
+;
+; It used to silently discard id characters appended to a multi-line
+; macro parameter (such as the x in %1x below).
+;
+%macro xxx 1
+%1: nop
+%{1}x: jmp %1x
+%endmacro
+xxx yyy
+
+%ifdef oldmsg
+;***************************************************************
+;
+; The following examples will generate error messages in 0.97 and will generate
+; correct output in the new version.
+
+;-----------------------------------------------------------------------------
+; Bug fixed by Simon in isns.dat
+;
+; The optional "near" was not permitted on JMP and CALL
+;
+ jmp near here
+
+;-----------------------------------------------------------------------------
+; Feature added by Simon in stdscan()
+;
+; You can now use the numeric value of strings in %assign
+;
+%assign xxx 'ABCD'
+ dd xxx
+
+;-----------------------------------------------------------------------------
+; Feature added by John in add_vectors()
+;
+; Stranger address expressions are now supported as long as they resolve to
+; something valid.
+;
+ mov ax, [eax + ebx + ecx - eax]
+
+;-----------------------------------------------------------------------------
+; Bug fixed by Simon in ???
+;
+; The EQU directive affected local labels in a way that was inconsistent
+; between passes
+;
+.local:
+neither equ $
+ jmp .local
+
+;-----------------------------------------------------------------------------
+; Feature added by Jules in parse_line
+;
+; You can override a size specifier
+;
+%define arg1 dword [bp+4]
+ cmp word arg1, 2
+
+;-----------------------------------------------------------------------------
+; Bug fixed by John in preproc.c
+;
+; You could not use a label on the same line with a macro invocation, if the
+; macro definition began with a preprocessor directive.
+;
+ struc mytype
+.long resd 1
+ endstruc
+
+lbl istruc mytype
+ at mytype.long, dd 'ABCD'
+ iend
+
+;-----------------------------------------------------------------------------
+; Warning removed by John in preproc.c
+;
+; In order to allow macros that extend the definition of instructions, I
+; disabled the warning on a multi-line macro referencing itself.
+;
+%endif ;NASM 0.97 doesn't handle %0 etc. inside false %if
+%macro push 1-* ;
+%rep %0 ;
+push %1 ;
+%rotate 1 ;
+%endrep ;
+%endmacro ;
+%ifdef oldmsg ;
+
+ push ax,bx
+
+;-----------------------------------------------------------------------------
+; Warning removed by John in preproc.c
+;
+; To support other types of macros that extend the definition of instructions,
+; I disabled the warning on a multi-line macro called with the wrong number of
+; parameters. PUSH and POP can be extended equally well by either method, but
+; other intruction extensions may need one method or the other, so I made both
+; work.
+;
+; Note that neither of these warnings was really needed, because a later stage
+; of NASM would almost always give an adequate error message if the macro use
+; really was wrong.
+;
+%endif
+%macro pop 2-*
+%rep %0
+pop %1
+%rotate 1
+%endrep
+%endmacro
+%ifdef oldmsg
+
+ pop ax,bx
+%endif
+
+
+%ifdef newmsg ;***************************************************************
+
+;-----------------------------------------------------------------------------
+; Bug fixed by John in parse_line() (and other routines)
+;
+; This invalid code used to assemble without errors
+;
+myself equ myself+1
+ jmp myself
+
+;-----------------------------------------------------------------------------
+; Change made by John in preproc.c
+;
+; In 0.97, an id that appears as a label on a macro invocation was always
+; prepended to the first line of the macro expansion. That caused several
+; bugs, but also could be used in tricks like the arg macro in c16.mac and
+; c32.mac.
+;
+; In version X, an id that appears as a label on a macro invocation will
+; normally be defined as a label for the address at which the macro is
+; invoked, regardless of whether the first line of the macro expansion is
+; something that can take a label. The new token %00 may be used for any
+; of the situations in which the old prepend behavior was doing something
+; tricky but useful. %00 can also be used more than once and in places
+; other than the start of the expansion.
+;
+%endif
+%assign arg_off 0
+
+%imacro arg 0-1 2 ;arg defined the old way
+ equ arg_off
+%assign arg_off %1+arg_off
+%endmacro
+
+%ifdef newmsg
+arg_example arg
+%endif
+
+%imacro arg2 0-1 2 ;arg defined the new way
+%00 equ arg_off
+%assign arg_off %1+arg_off
+%endmacro
+
+%ifdef oldmsg
+arg_example2 arg2
+
+;-----------------------------------------------------------------------------
+; Change made by Jules and John in INSNS.DAT
+;
+; Various instruction in which the size of an immediate is built-in to the
+; instruction set, now allow you to redundantly specify that size as long
+; as you specify it correctly
+;
+ AAD byte 5
+ AAM byte 5
+ BT bx, byte 3
+ BTC cx, byte 4
+ BTR dx, byte 5
+ BTS si, byte 6
+ IN eax, byte 0x40
+ INT byte 21h
+ OUT byte 70h, ax
+ RET word 2
+ RETN word 2
+ RETF word 4
+
+; note "ENTER" has not been changed yet.
+
+%endif
+
+%ifdef oldcrash ;*************************************************************
+
+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___
+
+;-----------------------------------------------------------------------------
+; Bug fixed by John in preproc.c
+;
+; Builds of NASM that prohibit dereferencing a NULL pointer used to crash if a
+; macro that started with a blank line was invoked with a label
+;
+%macro empty_macro 0
+
+%endm
+
+emlabel empty_macro
+ jmp emlabel
+
+%endif
+
+;-----------------------------------------------------------------------------
+; Enhancement by hpa in insns.dat et al
+;
+; Simplified added new instructions, and added some missing instructions
+;
+ int03 ; Instead of INT3
+ ud1 ; No documented mnemonic for this one
+ ud2
+ sysenter
+ sysexit
+ fxsave [ebx]
+ fxrstor [es:ebx+esi*4+0x3000]
+
+;-----------------------------------------------------------------------------
+; Enhancement by Conan Brink in preproc.c
+;
+; Allow %rep to be nested
+;
+%rep 4
+%rep 5
+ nop
+%endrep
+%endrep
AAA void \1\x37 8086
AAD void \2\xD5\x0A 8086
-AAD imm \1\xD5\24 8086,SB\r
+AAD imm \1\xD5\24 8086,SB
AAM void \2\xD4\x0A 8086
-AAM imm \1\xD4\24 8086,SB\r
+AAM imm \1\xD4\24 8086,SB
AAS void \1\x3F 8086
ADC mem,reg8 \300\1\x10\101 8086,SM
ADC reg8,reg8 \300\1\x10\101 8086
BT reg16,reg16 \320\300\2\x0F\xA3\101 386
BT mem,reg32 \321\300\2\x0F\xA3\101 386,SM
BT reg32,reg32 \321\300\2\x0F\xA3\101 386
-BT rm16,imm \320\300\2\x0F\xBA\204\25 386,SB\r
-BT rm32,imm \321\300\2\x0F\xBA\204\25 386,SB\r
+BT rm16,imm \320\300\2\x0F\xBA\204\25 386,SB
+BT rm32,imm \321\300\2\x0F\xBA\204\25 386,SB
BTC mem,reg16 \320\300\2\x0F\xBB\101 386,SM
BTC reg16,reg16 \320\300\2\x0F\xBB\101 386
BTC mem,reg32 \321\300\2\x0F\xBB\101 386,SM
BTC reg32,reg32 \321\300\2\x0F\xBB\101 386
-BTC rm16,imm \320\300\2\x0F\xBA\207\25 386,SB\r
-BTC rm32,imm \321\300\2\x0F\xBA\207\25 386,SB\r
+BTC rm16,imm \320\300\2\x0F\xBA\207\25 386,SB
+BTC rm32,imm \321\300\2\x0F\xBA\207\25 386,SB
BTR mem,reg16 \320\300\2\x0F\xB3\101 386,SM
BTR reg16,reg16 \320\300\2\x0F\xB3\101 386
BTR mem,reg32 \321\300\2\x0F\xB3\101 386,SM
BTR reg32,reg32 \321\300\2\x0F\xB3\101 386
-BTR rm16,imm \320\300\2\x0F\xBA\206\25 386,SB\r
-BTR rm32,imm \321\300\2\x0F\xBA\206\25 386,SB\r
+BTR rm16,imm \320\300\2\x0F\xBA\206\25 386,SB
+BTR rm32,imm \321\300\2\x0F\xBA\206\25 386,SB
BTS mem,reg16 \320\300\2\x0F\xAB\101 386,SM
BTS reg16,reg16 \320\300\2\x0F\xAB\101 386
BTS mem,reg32 \321\300\2\x0F\xAB\101 386,SM
BTS reg32,reg32 \321\300\2\x0F\xAB\101 386
-BTS rm16,imm \320\300\2\x0F\xBA\205\25 386,SB\r
-BTS rm32,imm \321\300\2\x0F\xBA\205\25 386,SB\r
+BTS rm16,imm \320\300\2\x0F\xBA\205\25 386,SB
+BTS rm32,imm \321\300\2\x0F\xBA\205\25 386,SB
CALL imm \322\1\xE8\64 8086
CALL imm|near \322\1\xE8\64 8086
CALL imm|far \322\1\x9A\34\37 8086,ND
IBTS reg16,reg16 \320\300\2\x0F\xA7\101 386,UNDOC,ND
IBTS mem,reg32 \321\300\2\x0F\xA7\101 386,SD,UNDOC,ND
IBTS reg32,reg32 \321\300\2\x0F\xA7\101 386,UNDOC,ND
-ICEBP void \1\xF1 P6,ND
+ICEBP void \1\xF1 386,ND
IDIV rm8 \300\1\xF6\207 8086
IDIV rm16 \320\300\1\xF7\207 8086
IDIV rm32 \321\300\1\xF7\207 386
IMUL reg16,imm \320\1\x69\100\31 286,SM
IMUL reg32,imm8 \321\1\x6B\100\15 386
IMUL reg32,imm \321\1\x69\100\41 386,SM
-IN reg_al,imm \1\xE4\25 8086,SB\r
-IN reg_ax,imm \320\1\xE5\25 8086,SB\r
-IN reg_eax,imm \321\1\xE5\25 386,SB\r
+IN reg_al,imm \1\xE4\25 8086,SB
+IN reg_ax,imm \320\1\xE5\25 8086,SB
+IN reg_eax,imm \321\1\xE5\25 386,SB
IN reg_al,reg_dx \1\xEC 8086
IN reg_ax,reg_dx \320\1\xED 8086
IN reg_eax,reg_dx \321\1\xED 386
INSB void \1\x6C 186
INSD void \321\1\x6D 386
INSW void \320\1\x6D 186
-INT imm \1\xCD\24 8086,SB\r
-INT01 void \1\xF1 P6,ND
-INT1 void \1\xF1 P6
+INT imm \1\xCD\24 8086,SB
+INT01 void \1\xF1 386,ND
+INT1 void \1\xF1 386
+INT03 void \1\xCC 8086,ND
INT3 void \1\xCC 8086
INTO void \1\xCE 8086
INVD void \2\x0F\x08 486
REST ignore ignore ignore
RESW ignore ignore ignore
RET void \1\xC3 8086
-RET imm \1\xC2\30 8086,SW\r
+RET imm \1\xC2\30 8086,SW
RETF void \1\xCB 8086
-RETF imm \1\xCA\30 8086,SW\r
+RETF imm \1\xCA\30 8086,SW
RETN void \1\xC3 8086
-RETN imm \1\xC2\30 8086,SW\r
+RETN imm \1\xC2\30 8086,SW
ROL rm8,unity \300\1\xD0\200 8086
ROL rm8,reg_cl \300\1\xD2\200 8086
ROL rm8,imm \300\1\xC0\200\25 186,SB
TEST mem,imm8 \300\1\xF6\200\21 8086,SM
TEST mem,imm16 \320\300\1\xF7\200\31 8086,SM
TEST mem,imm32 \321\300\1\xF7\200\41 386,SM
-UD1 void \2\x0F\xB9 286
+UD1 void \2\x0F\xB9 286,UNDOC
UD2 void \2\x0F\x0B 286
UMOV mem,reg8 \300\2\x0F\x10\101 386,UNDOC,SM
UMOV reg8,reg8 \300\2\x0F\x10\101 386,UNDOC
open (F, $fname) || die "unable to open $fname";
$line = 0;
-$opcodes = 0;
$insns = 0;
while (<F>) {
$line++;
$aname = "aa_$_[0]";
push @$aname, $formatted;
}
- $opcodes[$opcodes++] = $_[0], $done{$_[0]} = 1 if !$done{$_[0]};
+ if ( $_[0] =~ /cc$/ ) {
+ $k_opcodes_cc{$_[0]}++;
+ } else {
+ $k_opcodes{$_[0]}++;
+ }
+ $done{$_[0]} = 1 if !$done{$_[0]};
if ($formatted && !$nd) {
push @big, $formatted;
foreach $i (&startbyte($_[2])) {
close F;
+@opcodes = sort keys(%k_opcodes); # Unconditional instructions
+@opcodes_cc = sort keys(%k_opcodes_cc); # Conditional instructions
+
print STDERR "Writing insnsa.c...\n";
open A, ">insnsa.c";
print A "#include \"insns.h\"\n";
print A "\n";
-foreach $i (@opcodes) {
+foreach $i (@opcodes, @opcodes_cc) {
print A "static struct itemplate instrux_${i}[] = {\n";
$aname = "aa_$i";
foreach $j (@$aname) {
print A " {-1}\n};\n\n";
}
print A "struct itemplate *nasm_instructions[] = {\n";
-foreach $i (@opcodes) {
+foreach $i (@opcodes, @opcodes_cc) {
print A " instrux_${i},\n";
}
print A "};\n";
open I, ">insnsi.h";
print I "/* This file is auto-generated from insns.dat by insns.pl" .
- " - don't exit it */\n\n";
+ " - don't edit it */\n\n";
print I "/* This file in included by nasm.h */\n\n";
print I "/* Instruction names */\n";
print I "enum {";
$first = 1;
$maxlen = 0;
-foreach $i (@opcodes) {
+foreach $i (@opcodes, @opcodes_cc) {
print I "," if ( !$first );
$first = 0;
print I "\n\tI_${i}";
open N, ">insnsn.c";
print N "/* This file is auto-generated from insns.dat by insns.pl" .
- " - don't exit it */\n\n";
+ " - don't edit it */\n\n";
print N "/* This file in included by names.c */\n\n";
print N "static char *insn_names[] = {";
$first = 1;
foreach $i (@opcodes) {
- # Don't include conditional instructions
- if ( $i !~ /cc$/ ) {
- print N "," if ( !$first );
- $first = 0;
- $ilower = $i;
- $ilower =~ tr/A-Z/a-z/;
- print N "\n\t\"${ilower}\"";
- }
+ print N "," if ( !$first );
+ $first = 0;
+ $ilower = $i;
+ $ilower =~ tr/A-Z/a-z/; # Change to lower case (Perl 4 compatible)
+ print N "\n\t\"${ilower}\"";
}
print N "\n};\n\n";
print N "/* Conditional instructions */\n";
print N "static char *icn[] = {";
$first = 1;
-foreach $i (@opcodes) {
- # Only conditional instructions
- if ( $i =~ /cc$/ ) {
- $ins = $`; # Skip cc suffix
- print N "," if ( !$first );
- $first = 0;
- $ilower = $i;
- $ilower =~ tr/A-Z/a-z/;
- print N "\n\t\"${ilower}\"";
- }
+foreach $i (@opcodes_cc) {
+ print N "," if ( !$first );
+ $first = 0;
+ $ilower = $i;
+ $ilower =~ s/cc$//; # Skip cc suffix
+ $ilower =~ tr/A-Z/a-z/; # Change to lower case (Perl 4 compatible)
+ print N "\n\t\"${ilower}\"";
}
print N "\n};\n\n";
print N "/* and the corresponding opcodes */\n";
print N "static int ico[] = {";
$first = 1;
-foreach $i (@opcodes) {
- # Only conditional instructions
- if ( $i =~ /cc$/ ) {
- $ins = $`; # Skip cc suffix
- print N "," if ( !$first );
- $first = 0;
- print N "\n\tI_$i";
- }
+foreach $i (@opcodes_cc) {
+ print N "," if ( !$first );
+ $first = 0;
+ print N "\n\tI_$i";
}
print N "\n};\n";