NASM 0.98p3.3

This commit is contained in:
H. Peter Anvin 2002-04-30 20:55:37 +00:00
parent ce14ce6fc4
commit b64535fd4e
8 changed files with 398 additions and 380 deletions

View file

@ -2,22 +2,34 @@ This is a modified version of NASM, modified and released by H. Peter
Anvin <hpa@zytor.com>; it is not the original form released by the
NASM authors.
For release 0.98p3.3:
For release 0.98.3.2:
* Patch from Conan Brink to allow nesting of %rep directives.
* If we're going to allow INT01 as an alias for INT1/ICEBP (one of
John's J4 changes), then we should allow INT03 as an alias for INT3
as well.
* Updated changes.asm to include the latest changes.
* Tried to clean up the <CR>s that had snuck in from a DOS/Windows
environment into my Unix environment, and try to make sure than
DOS/Windows users get them back.
* We would silently generate broken tools if insns.dat wasn't sorted
properly. Change insns.pl so that the order doesn't matter.
* Fix bug in insns.pl (introduced by me) which would cause conditional
instructions to have an extra "cc" in disassembly, e.g. "jnz"
disassembled as "jccnz".
For release 0.98p3.2:
* Merged in John S. Fine's changes from his 0.98-J4 prerelease; see
http://www.csoft.net/cz/johnfine/
* Changed previous "spotless" Makefile target (appropriate for distribution)
to "distclean", and added "cleaner" target which is same as "clean"
except deletes files generated by Perl scripts; "spotless" is union.
* Removed BASIC programs from distribution. Get a Perl interpreter
instead (see below.)
* Calling this "pre-release 3.2" rather than "p3-hpa2" because of
John's contributions.
* Actually link in the IEEE output format (zoutieee.c); fix a bunch of
compiler warnings in that file. Note I don't know what IEEE output
is supposed to look like, so these changes were made "blind".
@ -27,17 +39,16 @@ For release 0.98p3-hpa:
* Merged nasm098p3.zip with nasm-0.97.tar.gz to create a fully
buildable version for Unix systems (Makefile.in updates, etc.)
* Changed insns.pl to create the instruction tables in nasm.h and
names.c, so that a new instruction can be added by adding it *only*
to insns.dat.
* Added the following new instructions: SYSENTER, SYSEXIT, FXSAVE,
FXRSTOR, UD1, UD2 (the latter two are two opcodes that Intel
guarantee will never be used; one of them is documented as UD2 in
Intel documentation, the other one just as "Undefined Opcode" --
calling it UD1 seemed to make sense.)
* MAX_SYMBOL was defined to be 9, but LOADALL286 and LOADALL386 are 10
characters long. Now MAX_SYMBOL is derived from insns.dat.
* A note on the BASIC programs included: forget them. insns.bas is
already out of date. Get yourself a Perl interpreter for your
platform of choice at:

View file

@ -91,7 +91,7 @@ clean:
cd rdoff; $(MAKE) clean
distclean: clean
rm -f config.* Makefile *~
rm -f config.* Makefile *~ *.bak changes.lst changes.bin
cd rdoff; $(MAKE) distclean
cleaner: clean

View file

@ -76,7 +76,7 @@ here: jmp .1
;
; Was not recognised as an instruction
;
int01
int01 ; Instead of INT1
;-----------------------------------------------------------------------------
; Bug fixed by Jim Hague in ???
@ -290,3 +290,27 @@ 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

View file

@ -397,7 +397,7 @@ IBTS mem,reg16 \320\300\2\x0F\xA7\101 386,SW,UNDOC,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
@ -436,8 +436,9 @@ INSB void \1\x6C 186
INSD void \321\1\x6D 386
INSW void \320\1\x6D 186
INT imm \1\xCD\24 8086,SB
INT01 void \1\xF1 P6,ND
INT1 void \1\xF1 P6
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
@ -1005,7 +1006,7 @@ TEST rm32,imm \321\300\1\xF7\200\41 386,SM
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

View file

@ -13,7 +13,6 @@ $fname = "insns.dat" unless $fname = $ARGV[0];
open (F, $fname) || die "unable to open $fname";
$line = 0;
$opcodes = 0;
$insns = 0;
while (<F>) {
$line++;
@ -28,7 +27,12 @@ while (<F>) {
$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])) {
@ -40,6 +44,9 @@ while (<F>) {
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";
@ -51,7 +58,7 @@ print A "#include \"nasm.h\"\n";
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) {
@ -60,7 +67,7 @@ foreach $i (@opcodes) {
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";
@ -107,14 +114,14 @@ print STDERR "Writing insnsi.h...\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}";
@ -132,49 +139,39 @@ print STDERR "Writing insnsn.c...\n";
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";

2
nasm.h
View file

@ -13,7 +13,7 @@
#define NASM_MAJOR_VER 0
#define NASM_MINOR_VER 98
#define NASM_VER "0.98 pre-release 3.2"
#define NASM_VER "0.98 pre-release 3.3"
#ifndef NULL
#define NULL 0

View file

@ -75,6 +75,7 @@ struct MMacro {
Line *expansion;
MMacro *next_active;
MMacro *rep_nest; /* used for nesting %rep */
Token **params; /* actual parameters */
Token *iline; /* invocation line */
int nparam, rotate, *paramlen;
@ -1156,6 +1157,7 @@ static int do_directive (Token *tline)
Line *l;
struct tokenval tokval;
expr *evalresult;
MMacro *tmp_defining; /* Used when manipulating rep_nest */
origline = tline;
@ -1472,6 +1474,7 @@ static int do_directive (Token *tline)
defining->plus = FALSE;
defining->nolist = FALSE;
defining->in_progress = FALSE;
defining->rep_nest = NULL;
tline = tline->next;
skip_white_(tline);
if (!tok_type_(tline, TOK_NUMBER)) {
@ -1590,24 +1593,6 @@ static int do_directive (Token *tline)
return 1;
case PP_REP:
if (defining) {
/*
* We don't allow nested %reps, because of a strange bug
* that was causing a panic. The cause of the bug appears to be
* that the nested %rep isn't taken into account when matching
* against the %endreps, so some mechanism to count the
* %reps in and the %endreps out may well work here.
*
* That's for experimentation with later, though.
* For informations sake, the panic produced by
* nesting %reps was:
*
* istk->mstk has no name but defining is set at end
* of expansion
*/
error(ERR_NONFATAL, "nested `%%rep' invocation not allowed");
break;
}
nolist = FALSE;
tline = tline->next;
if (tline->next && tline->next->type == TOK_WHITESPACE)
@ -1635,6 +1620,7 @@ static int do_directive (Token *tline)
"non-constant value given to `%%rep'");
return 3;
}
tmp_defining = defining;
defining = nasm_malloc(sizeof(MMacro));
defining->name = NULL; /* flags this macro as a %rep block */
defining->casesense = 0;
@ -1646,6 +1632,7 @@ static int do_directive (Token *tline)
defining->dlist = NULL;
defining->expansion = NULL;
defining->next_active = istk->mstk;
defining->rep_nest = tmp_defining;
return 1;
case PP_ENDREP:
@ -1675,7 +1662,8 @@ static int do_directive (Token *tline)
istk->mstk = defining;
list->uplevel (defining->nolist ? LIST_MACRO_NOLIST : LIST_MACRO);
defining = NULL;
tmp_defining = defining;
defining = defining->rep_nest;
free_tlist (origline);
return 1;
@ -2796,10 +2784,7 @@ static char *pp_getline (void)
if (defining->name)
error (ERR_PANIC,
"defining with name in expansion");
else if (!istk->mstk->name)
error (ERR_PANIC, "istk->mstk has no name but"
" defining is set at end of expansion");
else
else if (istk->mstk->name)
error (ERR_FATAL, "`%%rep' without `%%endrep' within"
" expansion of macro `%s'", istk->mstk->name);
}

View file

@ -63,7 +63,7 @@ clean:
rm -f *.o rdfdump ldrdf rdx rdflib rdf2bin rdf2com
distclean: clean
rm -f Makefile
rm -f Makefile *~ *.bak
cleaner: clean