NASM 0.97

This commit is contained in:
H. Peter Anvin 2002-04-30 20:53:16 +00:00
parent 76690a12ad
commit 87bc61964c
22 changed files with 827 additions and 195 deletions

47
Changes
View file

@ -129,8 +129,8 @@ be output when absolute labels were made global.
Updates to RDOFF subdirectory, and changes to outrdf.c.
0.95 not released yet
---------------------
0.95 released July 1997
-----------------------
Fixed yet another ELF bug. This one manifested if the user relied on
the default segment, and attempted to define global symbols without
@ -242,8 +242,8 @@ Fixed the implementation of WRT, which was too restrictive in that
you couldn't do `mov ax,[di+abc wrt dgroup]' because (di+abc) wasn't
a relocatable reference.
0.96 not released yet
---------------------
0.96 released November 1997
---------------------------
Fixed a bug whereby, if `nasm sourcefile' would cause a filename
collision warning and put output into `nasm.out', then `nasm
@ -403,3 +403,42 @@ assembled differently. This is important since [ESI+EBP] and
Added support for the PharLap OMF extension for 4096-byte segment
alignment.
0.97 released December 1997
---------------------------
This was entirely a bug-fix release to 0.96, which seems to have got
cursed. Silly me.
Fixed stupid mistake in OBJ which caused `MOV EAX,<constant>' to
fail. Caused by an error in the `MOV EAX,<segment>' support.
ndisasm hung at EOF when compiled with lcc on Linux because lcc on
Linux somehow breaks feof(). ndisasm now does not rely on feof().
A heading in the documentation was missing due to a markup error in
the indexing. Fixed.
Fixed failure to update all pointers on realloc() within extended-
operand code in parser.c. Was causing wrong behaviour and seg faults
on lines such as `dd 0.0,0.0,0.0,0.0,...'
Fixed a subtle preprocessor bug whereby invoking one multi-line
macro on the first line of the expansion of another, when the second
had been invoked with a label defined before it, didn't expand the
inner macro.
Added internal.doc back in to the distribution archives - it was
missing in 0.96 *blush*
Fixed bug causing 0.96 to be unable to assemble its own test files,
specifically objtest.asm. *blush again*
Fixed seg-faults and bogus error messages caused by mismatching
%rep and %endrep within multi-line macro definitions.
Fixed a problem with buffer overrun in OBJ, which was causing
corruption at ends of long PUBDEF records.
Separated DOS archives into main-program and documentation to reduce
download size.

81
Makefile.dj Normal file
View file

@ -0,0 +1,81 @@
# host: dos
# target: dos 32bit
# Makefile for the Netwide Assembler
#
# The Netwide Assembler is copyright (C) 1996 Simon Tatham and
# Julian Hall. All rights reserved. The software is
# redistributable under the licence given in the file "Licence"
# distributed in the NASM archive.
# makefile designed for djgpp 2.xx
# djgpp is GNU C compiler ported by mighty DJ Delorie
# www.delorie.com and any simtel mirror
# You may need to adjust these values.
CC = gcc
CFLAGS = -O2 -I.
# You _shouldn't_ need to adjust anything below this line.
.c.o:
$(CC) -c $(CFLAGS) $*.c
NASM = nasm.o nasmlib.o float.o insnsa.o assemble.o labels.o \
parser.o outform.o outbin.o outaout.o outcoff.o outelf.o \
outobj.o outas86.o outrdf.o outdbg.o preproc.o listing.o \
eval.o
NDISASM = ndisasm.o disasm.o sync.o nasmlib.o insnsd.o
all: nasm.exe ndisasm.exe
nasm.exe: $(NASM)
$(CC) -o $@ $(NASM)
ndisasm.exe: $(NDISASM)
$(CC) -o $@ $(NDISASM)
assemble.o: assemble.c nasm.h nasmlib.h assemble.h insns.h
disasm.o: disasm.c nasm.h disasm.h sync.h insns.h names.c
eval.o: eval.c eval.h nasm.h nasmlib.h
float.o: float.c nasm.h
insnsa.o: insnsa.c nasm.h insns.h
insnsd.o: insnsd.c nasm.h insns.h
labels.o: labels.c nasm.h nasmlib.h
listing.o: listing.c nasm.h nasmlib.h listing.h
nasm.o: nasm.c nasm.h nasmlib.h preproc.h parser.h assemble.h labels.h \
outform.h listing.h
nasmlib.o: nasmlib.c nasm.h nasmlib.h
ndisasm.o: ndisasm.c nasm.h nasmlib.h sync.h disasm.h
outaout.o: outaout.c nasm.h nasmlib.h outform.h
outas86.o: outas86.c nasm.h nasmlib.h outform.h
outbin.o: outbin.c nasm.h nasmlib.h outform.h
outcoff.o: outcoff.c nasm.h nasmlib.h outform.h
outdbg.o: outdbg.c nasm.h nasmlib.h outform.h
outelf.o: outelf.c nasm.h nasmlib.h outform.h
outform.o: outform.c outform.h nasm.h
outobj.o: outobj.c nasm.h nasmlib.h outform.h
outrdf.o: outrdf.c nasm.h nasmlib.h outform.h
parser.o: parser.c nasm.h nasmlib.h parser.h float.h names.c
preproc.o: preproc.c nasm.h nasmlib.h macros.c
sync.o: sync.c sync.h
# These two source files are automagically generated from a single
# instruction-table file by a Perl script. They're distributed,
# though, so it isn't necessary to have Perl just to recompile NASM
# from the distribution.
insnsa.c insnsd.c: insns.dat insns.pl
perl insns.pl insns.dat
# This source file is generated from the standard macros file
# `standard.mac' by another Perl script. Again, it's part of the
# standard distribution.
macros.c: standard.mac macros.pl
perl macros.pl standard.mac
clean:
rm -f *.o nasm ndisasm

110
Makefile.lcc Normal file
View file

@ -0,0 +1,110 @@
# host: windows nt/95
# target: windows nt/95
# Makefile for the Netwide Assembler
#
# The Netwide Assembler is copyright (C) 1996 Simon Tatham and
# Julian Hall. All rights reserved. The software is
# redistributable under the licence given in the file "Licence"
# distributed in the NASM archive.
# makefile designed for lcc-win32
# lcc-win32 is lcc (c compiler coded by guys from princeton uni)
# ported to win32 by jacob navia
# available at http://www.remcomp.com/lcc-win32/
CFLAGS = -c -O -g2
CC = lcc.exe $(CFLAGS)
LFLAGS = -subsystem console -s
LD = lcclnk.exe $(LFLAGS)
OBJ = obj
.c.${OBJ}:
$(CC) -o $@ $*.c
NASM = nasm.${OBJ} nasmlib.${OBJ} float.${OBJ} insnsa.${OBJ} assemble.${OBJ} labels.${OBJ} \
parser.${OBJ} outform.${OBJ} outbin.${OBJ} outaout.${OBJ} outcoff.${OBJ} outelf.${OBJ} \
outobj.${OBJ} outas86.${OBJ} outrdf.${OBJ} outdbg.${OBJ} preproc.${OBJ} listing.${OBJ} \
eval.${OBJ}
NDISASM = ndisasm.${OBJ} disasm.${OBJ} sync.${OBJ} nasmlib.${OBJ} insnsd.${OBJ}
all: nasm ndisasm
# linker response files
# that may take long, too much spawning command.com :)
NASM.LNK: makefile.lcc
echo nasm.$(OBJ) > NASM.LNK
echo nasmlib.$(OBJ) >> NASM.LNK
echo eval.$(OBJ) >> NASM.LNK
echo float.$(OBJ) >> NASM.LNK
echo insnsa.$(OBJ) >> NASM.LNK
echo assemble.$(OBJ) >> NASM.LNK
echo labels.$(OBJ) >> NASM.LNK
echo listing.$(OBJ) >> NASM.LNK
echo parser.$(OBJ) >> NASM.LNK
echo preproc.$(OBJ) >> NASM.LNK
echo outform.$(OBJ) >> NASM.LNK
echo outbin.$(OBJ) >> NASM.LNK
echo outaout.$(OBJ) >> NASM.LNK
echo outcoff.$(OBJ) >> NASM.LNK
echo outelf.$(OBJ) >> NASM.LNK
echo outobj.$(OBJ) >> NASM.LNK
echo outas86.$(OBJ) >> NASM.LNK
echo outrdf.$(OBJ) >> NASM.LNK
echo outdbg.$(OBJ) >> NASM.LNK
NDISASM.LNK: makefile.lcc
echo ndisasm.$(OBJ) > NDISASM.LNK
echo disasm.$(OBJ) >> NDISASM.LNK
echo sync.$(OBJ) >> NDISASM.LNK
echo nasmlib.$(OBJ) >> NDISASM.LNK
echo insnsd.$(OBJ) >> NDISASM.LNK
nasm: $(NASM) nasm.lnk
$(LD) -o nasm.exe @nasm.lnk
ndisasm: $(NDISASM) ndisasm.lnk
$(LD) -o ndisasm.exe @ndisasm.lnk
assemble.${OBJ}: assemble.c nasm.h nasmlib.h assemble.h insns.h
disasm.${OBJ}: disasm.c nasm.h disasm.h sync.h insns.h names.c
eval.${OBJ}: eval.c eval.h nasm.h nasmlib.h
float.${OBJ}: float.c nasm.h
insnsa.${OBJ}: insnsa.c nasm.h insns.h
insnsd.${OBJ}: insnsd.c nasm.h insns.h
labels.${OBJ}: labels.c nasm.h nasmlib.h
listing.${OBJ}: listing.c nasm.h nasmlib.h listing.h
nasm.${OBJ}: nasm.c nasm.h nasmlib.h preproc.h parser.h assemble.h labels.h \
outform.h listing.h
nasmlib.${OBJ}: nasmlib.c nasm.h nasmlib.h
ndisasm.${OBJ}: ndisasm.c nasm.h nasmlib.h sync.h disasm.h
outaout.${OBJ}: outaout.c nasm.h nasmlib.h outform.h
outas86.${OBJ}: outas86.c nasm.h nasmlib.h outform.h
outbin.${OBJ}: outbin.c nasm.h nasmlib.h outform.h
outcoff.${OBJ}: outcoff.c nasm.h nasmlib.h outform.h
outdbg.${OBJ}: outdbg.c nasm.h nasmlib.h outform.h
outelf.${OBJ}: outelf.c nasm.h nasmlib.h outform.h
outform.${OBJ}: outform.c outform.h nasm.h
outobj.${OBJ}: outobj.c nasm.h nasmlib.h outform.h
outrdf.${OBJ}: outrdf.c nasm.h nasmlib.h outform.h
parser.${OBJ}: parser.c nasm.h nasmlib.h parser.h float.h names.c
preproc.${OBJ}: preproc.c nasm.h nasmlib.h macros.c
sync.${OBJ}: sync.c sync.h
# These two source files are automagically generated from a single
# instruction-table file by a Perl script. They're distributed,
# though, so it isn't necessary to have Perl just to recompile NASM
# from the distribution.
insnsa.c insnsd.c: insns.dat insns.pl
perl insns.pl insns.dat
# This source file is generated from the standard macros file
# `standard.mac' by another Perl script. Again, it's part of the
# standard distribution.
macros.c: standard.mac macros.pl
perl macros.pl standard.mac
clean:
rm -f *.${OBJ} nasm.exe ndisasm.exe

7
Readme
View file

@ -41,6 +41,13 @@ To rebuild the DOS sources, various makefiles are provided:
- Makefile.wcw, also for Watcom C, compiling to a Win32 command-
line application. Also contributed by Dominik Behr.
- Makefile.dj, for DJGPP, compiling to a 32-bit extended DOS
executable. Contributed by Dominik Behr.
- Makefile.lcc, for lcc-win32, compiling to a Win32 command line
application. (The lcc-win32 compiler and tools are available from
http://www.remcomp.com/lcc-win32/)
I can't guarantee that all of those makefiles work, because I don't
have all of those compilers. However, Makefile.dos and Makefile.vc
work on my system, and so do Makefile.bor and Makefile.bc2.

View file

@ -1,11 +1,17 @@
NASM Wishlist
=============
- PUSH WORD EAX silently becomes PUSH EAX. Should warn.
- forward-reference tracking is instruction-granular not operand-
granular. Bummer.
- ndisasm hangs at eof.
- see if BITS can be made to do anything sensible in obj (eg set the
default new-segment property to Use32).
- missing heading in documentation - some subsect in chapter 4.
- __DATE__, __TIME__, and text variants of __NASM_MAJOR__ and
__NASM_MINOR__.
- Warn on TIMES combined with multi-line macros. TIMES gets applied
to first line only - should bring to users' attention.
- Add support for lcc 4.0.
* If-when this happens, remember to bump the `supported lcc

110
configure.in Normal file
View file

@ -0,0 +1,110 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(nasm.c)
dnl Check for broken VPATH handling on older NetBSD makes.
AC_DEFUN(AC_PROG_MAKE_VPATHOK,
[AC_MSG_CHECKING(whether ${MAKE-make} has sane VPATH handling)
set dummy ${MAKE-make}; ac_make=`echo "[$]2" | sed 'y%./+-%__p_%'`
AC_CACHE_VAL(ac_cv_prog_make_vpathok,
[mkdir conftestdir
cat > conftestdir/conftestmake <<\EOF
VPATH = ..
conftestfoo: conftestbar
@echo ac_make2temp=ok
conftestbar: conftestbaz
@echo ac_maketemp=broken
@touch conftestbar
EOF
echo > conftestbaz # these two lines need to be...
echo > conftestbar # ... in this order not the other
changequote(, )dnl
unset ac_maketemp
unset ac_make2temp
# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
eval `cd conftestdir; ${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
changequote([, ])dnl
if test -n "$ac_maketemp"; then
ac_cv_prog_make_vpathok=no
else
if test -n "$ac_make2temp"; then
ac_cv_prog_make_vpathok=yes
else
ac_cv_prog_make_vpathok=no
fi
fi
rm -rf conftestdir
rm -f conftestbar conftestbaz])dnl
if test $ac_cv_prog_make_vpathok = yes; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
])
AC_PREFIX_PROGRAM(nasm)
dnl Checks for programs.
AC_PROG_CC
AC_PROG_LN_S
AC_PROG_MAKE_SET
if test -f nasm.c; then
# we're building in the source dir, so we don't need this check at all
ac_cv_prog_make_vpathok=yes
else
AC_PROG_MAKE_VPATHOK
fi
AC_PROG_INSTALL
if test "$GCC" = "yes"; then
GCCFLAGS="-Wall -ansi -pedantic"
else
GCCFLAGS=
fi
AC_SUBST(GCCFLAGS)
dnl Checks for header files.
AC_HEADER_STDC
if test $ac_cv_header_stdc = no; then
AC_MSG_ERROR([NASM requires ANSI C header files to compile])
fi
AC_CHECK_HEADERS(limits.h)
if test $ac_cv_header_limits_h = no; then
AC_MSG_ERROR([NASM requires '<limits.h>' to compile])
fi
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
if test $ac_cv_c_const = no; then
AC_MSG_ERROR([NASM requires ANSI C (specifically, working "const")])
fi
AC_TYPE_SIZE_T
if test $ac_cv_type_size_t = no; then
AC_MSG_ERROR([NASM requires ANSI C (specifically, "size_t")])
fi
dnl Checks for library functions.
AC_FUNC_VPRINTF
if test $ac_cv_func_vprintf = no; then
AC_MSG_ERROR([NASM requires ANSI C (specifically, "vprintf" and friends)])
fi
AC_CHECK_FUNCS(strcspn)
if test $ac_cv_func_strcspn = no; then
AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")])
fi
AC_CHECK_FUNCS(strspn)
if test $ac_cv_func_strspn = no; then
AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")])
fi
if test $ac_cv_prog_make_vpathok = no; then
echo Copying generated srcs into build directory to compensate for VPATH breakage
if test ! -f insnsa.c; then cp -p ${srcdir}/insnsa.c .; fi
if test ! -f insnsd.c; then cp -p ${srcdir}/insnsd.c .; fi
if test ! -f macros.c; then cp -p ${srcdir}/macros.c .; fi
fi
AC_OUTPUT(Makefile rdoff/Makefile)

View file

@ -1411,6 +1411,19 @@ then no other definition of \c{foo} will be accepted: a macro with
no parameters prohibits the definition of the same name as a macro
\e{with} parameters, and vice versa.
This doesn't prevent single-line macros being \e{redefined}: you can
perfectly well define a macro with
\c %define foo bar
and then re-define it later in the same source file with
\c %define foo baz
Then everywhere the macro \c{foo} is invoked, it will be expanded
according to the most recent definition. This is particularly useful
when defining single-line macros with \c{%assign} (see \k{assign}).
You can \i{pre-define} single-line macros using the `-d' option on
the NASM command line: see \k{opt-d}.
@ -1426,6 +1439,13 @@ parameters and have a numeric value. This value can be specified in
the form of an expression, and it will be evaluated once, when the
\c{%assign} directive is processed.
Like \c{%define}, macros defined using \c{%assign} can be re-defined
later, so you can do things like
\c %assign i i+1
to increment the numeric value of a macro.
\c{%assign} is useful for controlling the termination of \c{%rep}
preprocessor loops: see \k{rep} for an example of this. Another
use for \c{%assign} is given in \k{16c} and \k{32c}.
@ -1480,7 +1500,7 @@ things like
\c silly 'ab', string_ab ; string_ab: db 'ab'
\c silly {13,10}, crlf ; crlf: db 13,10
\S{mlmacover} \I{Overloading Multi-Line Macros}
\S{mlmacover} \i{Overloading Multi-Line Macros}
As with single-line macros, multi-line macros can be overloaded by
defining the same macro name several times with different numbers of

View file

@ -533,3 +533,4 @@ FUNCTION StrTrimRight$ (a$, b$) 'public
StrTrimRight$ = LEFT$(a$, p)
END FUNCTION


250
install-sh Executable file
View file

@ -0,0 +1,250 @@
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

View file

@ -173,3 +173,4 @@ FUNCTION StrTrimRight$ (a$, b$) 'public
StrTrimRight$ = LEFT$(a$, p)
END FUNCTION


View file

@ -2,7 +2,7 @@
static char *stdmac[] = {
"%define __NASM_MAJOR__ 0",
"%define __NASM_MINOR__ 96",
"%define __NASM_MINOR__ 97",
"%define __FILE__",
"%define __LINE__",
"%define __SECT__",

70
makedist.sh Executable file
View file

@ -0,0 +1,70 @@
#!/bin/sh
MAJORVER=`grep NASM_MAJOR_VER nasm.h | head -1 | cut -f3 -d' '`
MINORVER=`grep NASM_MINOR_VER nasm.h | head -1 | cut -f3 -d' '`
VERSION="${MAJORVER}.${MINORVER}"
DOSVERSION="${MAJORVER}${MINORVER}"
NASM_TAR_GZ=dist/nasm-${VERSION}.tar.gz
NASM_ZIP=dist/nasm${DOSVERSION}s.zip
NASM_DOS_ZIP=dist/nasm${DOSVERSION}.zip
NASM_DOC_ZIP=dist/nasm${DOSVERSION}d.zip
if [ -d dist ]; then rm -rf dist; fi
if [ -d nasm-${VERSION} ]; then rm -rf nasm-${VERSION}; fi
if [ ! -d dist ]; then mkdir dist; fi
if [ -f dist/nasm.tar.gz ]; then rm dist/nasm.tar.gz; fi
mkdir nasm-${VERSION}
(cd nasm-${VERSION}; ln -s ../* .;
rm -f nasm-${VERSION} dist Checklist GNUmakefile z*)
find nasm-${VERSION}/ -follow -name GNUmakefile > tar-exclude
find nasm-${VERSION}/ -follow -name RCS >> tar-exclude
find nasm-${VERSION}/ -follow -name '*.exe' >> tar-exclude
find nasm-${VERSION}/ -follow -name '*.uu' >> tar-exclude
find nasm-${VERSION}/ -follow -name '*,v' >> tar-exclude
for i in nasm-${VERSION}/doc/{nasmdoc.hpj,nasmdoc.rtf,nasmdoc.texi,Readme};
do echo $i; done >> tar-exclude
tar chvfX dist/nasm-${VERSION}.tar tar-exclude nasm-${VERSION}
rm -f tar-exclude
tar tf dist/nasm-${VERSION}.tar | (echo nasm.doc; sed \
-e 's:^nasm-[^/]*/::' \
-e 's:/$::' \
-e '/install-sh/d' \
-e '/makedist\.sh/d' \
-e '/exasm\.zip/d' \
-e '/config/d' \
-e '/doc\/.*\.html/d' \
-e '/doc\/Readme/d' \
-e '/doc\/nasmdoc\.ps/d' \
-e '/doc\/nasmdoc\.txt/d' \
-e '/doc\/nasmdoc\.rtf/d' \
-e '/doc\/nasmdoc\.hpj/d' \
-e '/doc\/nasmdoc\.texi/d' \
-e '/doc\/nasmdoc\.hlp/d' \
-e '/doc\/nasm\.info/d' \
) | sort > zipfiles
sed \
-e '/^[^\/]*\.\(c\|h\|pl\|bas\|dat\)$/d' \
-e '/^doc\(\/.*\)\?/d' \
-e '/standard\.mac/d' \
-e '/Makefile/d' \
-e '/rdoff/d' \
< zipfiles > zipfiles.dos
gzip -9 dist/nasm-${VERSION}.tar
rm -rf nasm-${VERSION}
ln -s doc/nasmdoc.src nasm.doc
zip -l -k ${NASM_ZIP} `cat zipfiles`
zip -k ${NASM_ZIP} *.exe misc/exasm.zip
zip -l -k ${NASM_DOS_ZIP} `cat zipfiles.dos`
zip -k ${NASM_DOS_ZIP} *.exe misc/exasm.zip
rm -f nasm.doc
(cd doc; zip -l -k ../${NASM_DOC_ZIP} \
Readme \
nasmdoc.src rdsrc.pl \
nasmdoc.txt \
nasmdoc.ps \
*.html
zip -k ../${NASM_DOC_ZIP} \
nasmdoc.hlp \
nasm.info)
rm -f zipfiles zipfiles.dos
echo Distributions complete.

4
nasm.h
View file

@ -12,8 +12,8 @@
#define NASM_NASM_H
#define NASM_MAJOR_VER 0
#define NASM_MINOR_VER 96
#define NASM_VER "0.96"
#define NASM_MINOR_VER 97
#define NASM_VER "0.97"
#ifndef NULL
#define NULL 0

View file

@ -853,27 +853,34 @@ int is_really_simple (expr *vect) {
* scalar, plus at most one segment-base, plus possibly a WRT).
*/
int is_reloc (expr *vect) {
while (vect->type && !vect->value)
while (vect->type && !vect->value) /* skip initial value-0 terms */
vect++;
if (!vect->type)
return 1;
if (vect->type < EXPR_SIMPLE)
if (!vect->type) /* trivially return TRUE if nothing */
return 1; /* is present apart from value-0s */
if (vect->type < EXPR_SIMPLE) /* FALSE if a register is present */
return 0;
if (vect->type == EXPR_SIMPLE) {
if (vect->type == EXPR_SIMPLE) { /* skip over a pure number term... */
do {
vect++;
} while (vect->type && !vect->value);
if (!vect->type)
if (!vect->type) /* ...returning TRUE if that's all */
return 1;
}
if (vect->type != EXPR_WRT && vect->value != 0 && vect->value != 1)
if (vect->type == EXPR_WRT) { /* skip over a WRT term... */
do {
vect++;
} while (vect->type && !vect->value);
if (!vect->type) /* ...returning TRUE if that's all */
return 1;
}
if (vect->value != 0 && vect->value != 1)
return 0; /* segment base multiplier non-unity */
do {
do { /* skip over _one_ seg-base term... */
vect++;
} while (vect->type && (vect->type == EXPR_WRT || !vect->value));
if (!vect->type)
} while (vect->type && !vect->value);
if (!vect->type) /* ...returning TRUE if that's all */
return 1;
return 0;
return 0; /* And return FALSE if there's more */
}
/*

View file

@ -42,6 +42,7 @@ int main(int argc, char **argv) {
int lenread, lendis;
int autosync = FALSE;
int bits = 16;
int eof = FALSE;
int rn_error;
long offset;
FILE *fp;
@ -191,6 +192,8 @@ int main(int argc, char **argv) {
if (to_read > nextsync-offset-(p-q))
to_read = nextsync-offset-(p-q);
lenread = fread (p, 1, to_read, fp);
if (lenread == 0)
eof = TRUE; /* help along systems with bad feof */
p += lenread;
if (offset == nextsync) {
if (synclen) {
@ -218,7 +221,7 @@ int main(int argc, char **argv) {
p -= (q - buffer);
q = buffer;
}
} while (lenread > 0 || !feof(fp));
} while (lenread > 0 || !(eof || feof(fp)));
fclose (fp);
return 0;
}

View file

@ -599,7 +599,8 @@ static void obj_out (long segto, void *data, unsigned long type,
datacurr->lptr = obj_write_dword (datacurr->lptr, ldata);
datacurr->nonempty = TRUE;
rsize = size;
if (segment < SEG_ABS && segment % 2 && size == 4) {
if (segment < SEG_ABS && (segment != NO_SEG && segment % 2) &&
size == 4) {
/*
* This is a 4-byte segment-base relocation such as
* `MOV EAX,SEG foo'. OBJ format can't actually handle
@ -1519,7 +1520,7 @@ static void obj_write_file (void) {
else
rectype = PUBDEF;
for (pub = seg->pubhead; pub; pub = pub->next) {
if (recptr - record + strlen(pub->name) > 1024) {
if (recptr - record + strlen(pub->name) + 7 > 1024) {
if (any)
obj_record (rectype, record, recptr);
recptr = record;

View file

@ -221,6 +221,10 @@ static long rdf_section_names(char *name, int pass, int *bits)
static void write_reloc_rec(struct RelocRec *r)
{
if (r->refseg != NO_SEG && (r->refseg & 1))
error (ERR_NONFATAL, "RDF format does not support segment base"
" references");
r->refseg >>= 1; /* adjust segment nos to RDF rather than NASM */
membufwrite(header,&r->type,1);
@ -465,7 +469,7 @@ static void rdf_cleanup (void) {
}
static long rdf_segbase (long segment) {
return 0;
return segment;
}
static int rdf_directive (char *directive, char *value, int pass) {

View file

@ -179,7 +179,7 @@ insn *parse_line (int pass, char *buffer, insn *result,
result->opcode == I_DQ ||
result->opcode == I_DT ||
result->opcode == I_INCBIN) {
extop *eop, **tail = &result->eops;
extop *eop, **tail = &result->eops, **fixptr;
int oper_num = 0;
/*
@ -189,6 +189,7 @@ insn *parse_line (int pass, char *buffer, insn *result,
i = stdscan(NULL, &tokval);
if (i == 0)
break;
fixptr = tail;
eop = *tail = nasm_malloc(sizeof(extop));
tail = &eop->next;
eop->next = NULL;
@ -231,6 +232,8 @@ insn *parse_line (int pass, char *buffer, insn *result,
eop->type = EOT_NOTHING;
}
eop = nasm_realloc(eop, sizeof(extop)+eop->stringlen);
tail = &eop->next;
*fixptr = eop;
eop->stringval = (char *)eop + sizeof(extop);
if (!float_const (tokval.t_charptr, sign,
(unsigned char *)eop->stringval,

View file

@ -2604,9 +2604,17 @@ static int expand_mmacro (Token *tline) {
/*
* If we had a label, push it on the front of the first line of
* the macro expansion.
* the macro expansion. We must check that this doesn't give
* two consecutive TOK_WHITESPACE.
*/
if (label) {
if (last->type == TOK_WHITESPACE &&
istk->expansion->first->type == TOK_WHITESPACE) {
Token *victim = istk->expansion->first; /* kill this whitespace */
istk->expansion->first = victim->next;
nasm_free (victim->text);
nasm_free (victim);
}
last->next = istk->expansion->first;
istk->expansion->first = label;
}
@ -2706,6 +2714,25 @@ static char *pp_getline (void) {
}
line_sync();
} else {
/*
* Check whether a `%rep' was started and not ended
* within this macro expansion. This can happen and
* should be detected. It's a fatal error because
* I'm too confused to work out how to recover
* sensibly from it.
*/
if (defining) {
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
error (ERR_FATAL, "`%%rep' without `%%endrep' within"
" expansion of macro `%s'", istk->mstk->name);
}
if (istk->mstk->name) {
/*
* This was a real macro call, not a %rep, and

View file

@ -1,53 +0,0 @@
# Makefile for RDOFF object file utils; part of the Netwide Assembler
#
# The Netwide Assembler is copyright (C) 1996 Simon Tatham and
# Julian Hall. All rights reserved. The software is
# redistributable under the licence given in the file "Licence"
# distributed in the NASM archive.
#
# This Makefile is designed for use under Unix (probably fairly
# portably).
CC = gcc
CCFLAGS = -c -g -Wall -ansi -pedantic -I..
LINK = gcc
LINKFLAGS = -g -o
DLINKFLAGS = -o
LIBRARIES =
STRIP = strip
LDRDFLIBS = rdoff.o ../nasmlib.o symtab.o collectn.o rdlib.o
RDXLIBS = rdoff.o rdfload.o symtab.o collectn.o
.c.o:
$(CC) $(CCFLAGS) $*.c
all : rdfdump ldrdf rdx rdflib rdf2bin rdf2com
rdfdump : rdfdump.o
$(LINK) $(LINKFLAGS) rdfdump rdfdump.o
ldrdf : ldrdf.o $(LDRDFLIBS)
$(LINK) $(LINKFLAGS) ldrdf ldrdf.o $(LDRDFLIBS)
rdx : rdx.o $(RDXLIBS)
$(LINK) $(LINKFLAGS) rdx rdx.o $(RDXLIBS)
rdflib : rdflib.o
$(LINK) $(LINKFLAGS) rdflib rdflib.o
rdf2bin : rdf2bin.o $(RDXLIBS) ../nasmlib.o
$(LINK) $(LINKFLAGS) rdf2bin rdf2bin.o $(RDXLIBS) ../nasmlib.o
rdf2com :
ln -s rdf2bin rdf2com
rdf2bin.o : rdf2bin.c
rdfdump.o : rdfdump.c
rdoff.o : rdoff.c rdoff.h
ldrdf.o : ldrdf.c rdoff.h ../nasmlib.h symtab.h collectn.h rdlib.h
symtab.o : symtab.c symtab.h
collectn.o : collectn.c collectn.h
rdx.o : rdx.c rdoff.h rdfload.h symtab.h
rdfload.o : rdfload.c rdfload.h rdoff.h collectn.h symtab.h
rdlib.o : rdlib.c rdlib.h
rdflib.o : rdflib.c
clean :
rm -f *.o *~ rdfdump ldrdf rdx rdflib rdf2bin

View file

@ -1,112 +1,57 @@
# Makefile for RDOFF object file utils; part of the Netwide Assembler
#
# The Netwide Assembler is copyright (C) 1996 Simon Tatham and
# Julian Hall. All rights reserved. The software is
# redistributable under the licence given in the file "Licence"
# distributed in the NASM archive.
#
# This Makefile is designed for use under Unix (probably fairly
# portably).
CC = sc
CCFLAGS = -I..\ -c -a1 -mn -Nc -w2 -w7 -o+time -5
LINK = link
LINKFLAGS = /noi /exet:NT /su:console
OBJ=obj
EXE=.exe
NASMLIB = ..\nasmlib.$(OBJ)
NASMLIB_H = ..\nasmlib.h
LDRDFLIBS = rdoff.$(OBJ) $(NASMLIB) symtab.$(OBJ) collectn.$(OBJ) rdlib.$(OBJ)
RDXLIBS = rdoff.$(OBJ) rdfload.$(OBJ) symtab.$(OBJ) collectn.$(OBJ)
.c.$(OBJ):
$(CC) $(CCFLAGS) $*.c
all : rdfdump$(EXE) ldrdf$(EXE) rdx$(EXE) rdflib$(EXE) rdf2bin$(EXE) rdf2com$(EXE)
rdfdump$(EXE) : rdfdump.$(OBJ)
$(LINK) $(LINKFLAGS) rdfdump.$(OBJ), rdfdump$(EXE);
ldrdf$(EXE) : ldrdf.$(OBJ) $(LDRDFLIBS)
$(LINK) $(LINKFLAGS) ldrdf.$(OBJ) $(LDRDFLIBS), ldrdf$(EXE);
rdx$(EXE) : rdx.$(OBJ) $(RDXLIBS)
$(LINK) $(LINKFLAGS) rdx.$(OBJ) $(RDXLIBS), rdx$(EXE);
rdflib$(EXE) : rdflib.$(OBJ)
$(LINK) $(LINKFLAGS) rdflib.$(OBJ), rdflib$(EXE);
rdf2bin$(EXE) : rdf2bin.$(OBJ) $(RDXLIBS) $(NASMLIB)
$(LINK) $(LINKFLAGS) rdf2bin.$(OBJ) $(RDXLIBS) $(NASMLIB), rdf2bin$(EXE);
rdf2com$(EXE) : rdf2bin$(EXE)
copy rdf2bin$(EXE) rdf2com$(EXE)
rdf2bin.$(OBJ) : rdf2bin.c
rdfdump.$(OBJ) : rdfdump.c
rdoff.$(OBJ) : rdoff.c rdoff.h
ldrdf.$(OBJ) : ldrdf.c rdoff.h $(NASMLIB_H) symtab.h collectn.h rdlib.h
symtab.$(OBJ) : symtab.c symtab.h
collectn.$(OBJ) : collectn.c collectn.h
rdx.$(OBJ) : rdx.c rdoff.h rdfload.h symtab.h
rdfload.$(OBJ) : rdfload.c rdfload.h rdoff.h collectn.h symtab.h
rdlib.$(OBJ) : rdlib.c rdlib.h
rdflib.$(OBJ) : rdflib.c
clean :
del *.$(OBJ) rdfdump$(EXE) ldrdf$(EXE) rdx$(EXE) rdflib$(EXE) rdf2bin$(EXE)
# Makefile for RDOFF object file utils; part of the Netwide Assembler
#
# The Netwide Assembler is copyright (C) 1996 Simon Tatham and
# Julian Hall. All rights reserved. The software is
# redistributable under the licence given in the file "Licence"
# distributed in the NASM archive.
#
# This Makefile is designed for use under Unix (probably fairly
# portably).
CC = sc
CCFLAGS = -I..\ -c -a1 -mn -Nc -w2 -w7 -o+time -5
LINK = link
LINKFLAGS = /noi /exet:NT /su:console
OBJ=obj
EXE=.exe
NASMLIB = ..\nasmlib.$(OBJ)
NASMLIB_H = ..\nasmlib.h
LDRDFLIBS = rdoff.$(OBJ) $(NASMLIB) symtab.$(OBJ) collectn.$(OBJ) rdlib.$(OBJ)
RDXLIBS = rdoff.$(OBJ) rdfload.$(OBJ) symtab.$(OBJ) collectn.$(OBJ)
.c.$(OBJ):
$(CC) $(CCFLAGS) $*.c
all : rdfdump$(EXE) ldrdf$(EXE) rdx$(EXE) rdflib$(EXE) rdf2bin$(EXE) rdf2com$(EXE)
rdfdump$(EXE) : rdfdump.$(OBJ)
$(LINK) $(LINKFLAGS) rdfdump.$(OBJ), rdfdump$(EXE);
ldrdf$(EXE) : ldrdf.$(OBJ) $(LDRDFLIBS)
$(LINK) $(LINKFLAGS) ldrdf.$(OBJ) $(LDRDFLIBS), ldrdf$(EXE);
rdx$(EXE) : rdx.$(OBJ) $(RDXLIBS)
$(LINK) $(LINKFLAGS) rdx.$(OBJ) $(RDXLIBS), rdx$(EXE);
rdflib$(EXE) : rdflib.$(OBJ)
$(LINK) $(LINKFLAGS) rdflib.$(OBJ), rdflib$(EXE);
rdf2bin$(EXE) : rdf2bin.$(OBJ) $(RDXLIBS) $(NASMLIB)
$(LINK) $(LINKFLAGS) rdf2bin.$(OBJ) $(RDXLIBS) $(NASMLIB), rdf2bin$(EXE);
rdf2com$(EXE) : rdf2bin$(EXE)
copy rdf2bin$(EXE) rdf2com$(EXE)
rdf2bin.$(OBJ) : rdf2bin.c
rdfdump.$(OBJ) : rdfdump.c
rdoff.$(OBJ) : rdoff.c rdoff.h
ldrdf.$(OBJ) : ldrdf.c rdoff.h $(NASMLIB_H) symtab.h collectn.h rdlib.h
symtab.$(OBJ) : symtab.c symtab.h
collectn.$(OBJ) : collectn.c collectn.h
rdx.$(OBJ) : rdx.c rdoff.h rdfload.h symtab.h
rdfload.$(OBJ) : rdfload.c rdfload.h rdoff.h collectn.h symtab.h
rdlib.$(OBJ) : rdlib.c rdlib.h
rdflib.$(OBJ) : rdflib.c
clean :
del *.$(OBJ) rdfdump$(EXE) ldrdf$(EXE) rdx$(EXE) rdflib$(EXE) rdf2bin$(EXE)


View file

@ -1,10 +1,10 @@
; Standard macro set for NASM 0.96 -*- nasm -*-
; Standard macro set for NASM 0.97 -*- nasm -*-
; Note that although some user-level forms of directives are defined
; here, not all of them are: the user-level form of a format-specific
; directive should be defined in the module for that directive.
%define __NASM_MAJOR__ 0
%define __NASM_MINOR__ 96
%define __NASM_MINOR__ 97
; These two need to be defined, though the actual definitions will
; be constantly updated during preprocessing.