summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-05-20 14:21:29 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-05-20 14:21:29 -0700
commita4835d466c50237afcc30ff99bc980aeb5d17ce6 (patch)
tree66357bce22a451743c6b1b02e71f6860d9d84bd2
parent73252a92ae00ab63a6f52f9c987d4550c20b9100 (diff)
downloadnasm-a4835d466c50237afcc30ff99bc980aeb5d17ce6.tar.gz
nasm-a4835d466c50237afcc30ff99bc980aeb5d17ce6.tar.bz2
nasm-a4835d466c50237afcc30ff99bc980aeb5d17ce6.zip
Avoid #including .c files; instead compile as separate units
Don't #include .c files, even if they are auto-generated; instead compile them as separate compilation units and let the linker do its job.
-rw-r--r--Makefile.in41
-rw-r--r--Mkfiles/msvc.mak33
-rw-r--r--Mkfiles/netware.mak85
-rw-r--r--Mkfiles/openwcom.mak42
-rw-r--r--Mkfiles/owlinux.mak40
-rw-r--r--assemble.c33
-rw-r--r--disasm.c86
-rw-r--r--insns.pl10
-rw-r--r--macros.pl9
-rw-r--r--names.c20
-rw-r--r--parser.c13
-rw-r--r--preproc.c10
-rwxr-xr-xregs.pl28
-rw-r--r--tables.h36
14 files changed, 248 insertions, 238 deletions
diff --git a/Makefile.in b/Makefile.in
index 914c874..9fe7695 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -65,11 +65,12 @@ NASM = nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
output/outelf32.$(O) output/outelf64.$(O) \
output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
- preproc.$(O) pptok.$(O) \
- listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O)
+ preproc.$(O) pptok.$(O) macros.$(O) \
+ listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O) \
+ regvals.$(O) regflags.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) \
- insnsd.$(O) insnsb.$(O)
+ insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
all: nasm$(X) ndisasm$(X) nasm.man ndisasm.man
cd rdoff && $(MAKE) all
@@ -122,6 +123,8 @@ regflags.c: regs.dat regs.pl
$(PERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c
regdis.c: regs.dat regs.pl
$(PERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c
+regdis.h: regs.dat regs.pl
+ $(PERL) $(srcdir)/regs.pl dh $(srcdir)/regs.dat > regdis.h
regvals.c: regs.dat regs.pl
$(PERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c
regs.h: regs.dat regs.pl
@@ -146,8 +149,9 @@ pptok.c: pptok.dat pptok.pl perllib/phash.ph
# This target generates all files that require perl.
# This allows easier generation of distribution (see dist target).
PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
- regs.c regs.h regflags.c regdis.c regvals.c tokhash.c tokens.h \
- version.h version.mac pptok.h pptok.c
+ regs.c regs.h regflags.c regdis.c regdis.h regvals.c \
+ tokhash.c tokens.h pptok.h pptok.c \
+ version.h version.mac
perlreq: $(PERLREQ)
install: nasm$(X) ndisasm$(X)
@@ -228,11 +232,10 @@ alldeps: perlreq
# @path-separator: "/"
#-- Everything below is generated by mkdep.pl - do not edit --#
assemble.$(O): assemble.c assemble.h compiler.h config.h insns.h insnsi.h \
- nasm.h nasmlib.h pptok.h preproc.h regflags.c regs.h regvals.c tokens.h \
- version.h
+ nasm.h nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h version.h
crc64.$(O): crc64.c compiler.h config.h
-disasm.$(O): disasm.c compiler.h config.h disasm.h insns.h insnsi.h insnsn.c \
- names.c nasm.h nasmlib.h regdis.c regs.c regs.h sync.h tokens.h version.h
+disasm.$(O): disasm.c compiler.h config.h disasm.h insns.h insnsi.h nasm.h \
+ nasmlib.h regdis.h regs.h sync.h tables.h tokens.h version.h
eval.$(O): eval.c compiler.h config.h eval.h float.h insnsi.h labels.h \
nasm.h nasmlib.h regs.h version.h
exprlib.$(O): exprlib.c compiler.h config.h insnsi.h nasm.h nasmlib.h regs.h \
@@ -247,15 +250,14 @@ insnsb.$(O): insnsb.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
regs.h tokens.h version.h
insnsd.$(O): insnsd.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
regs.h tokens.h version.h
-insnsn.$(O): insnsn.c
+insnsn.$(O): insnsn.c compiler.h config.h insnsi.h tables.h
labels.$(O): labels.c compiler.h config.h hashtbl.h insnsi.h nasm.h \
nasmlib.h regs.h version.h
lib/snprintf.$(O): lib/snprintf.c compiler.h config.h nasmlib.h
lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h config.h nasmlib.h
listing.$(O): listing.c compiler.h config.h insnsi.h listing.h nasm.h \
nasmlib.h regs.h version.h
-macros.$(O): macros.c compiler.h config.h
-names.$(O): names.c compiler.h config.h insnsn.c regs.c
+macros.$(O): macros.c compiler.h config.h insnsi.h tables.h
nasm.$(O): nasm.c assemble.h compiler.h config.h eval.h float.h insns.h \
insnsi.h labels.h listing.h nasm.h nasmlib.h outform.h parser.h pptok.h \
preproc.h regs.h stdscan.h tokens.h version.h
@@ -290,15 +292,16 @@ output/outrdf.$(O): output/outrdf.c compiler.h config.h insnsi.h nasm.h \
output/outrdf2.$(O): output/outrdf2.c compiler.h config.h insnsi.h nasm.h \
nasmlib.h outform.h rdoff/rdoff.h regs.h version.h
parser.$(O): parser.c compiler.h config.h float.h insns.h insnsi.h nasm.h \
- nasmlib.h parser.h regflags.c regs.h stdscan.h tokens.h version.h
+ nasmlib.h parser.h regs.h stdscan.h tables.h tokens.h version.h
pptok.$(O): pptok.c compiler.h config.h hashtbl.h nasmlib.h pptok.h \
preproc.h
-preproc.$(O): preproc.c compiler.h config.h hashtbl.h insnsi.h macros.c \
- nasm.h nasmlib.h pptok.h preproc.h regs.h stdscan.h tokens.h version.h
-regdis.$(O): regdis.c
-regflags.$(O): regflags.c
-regs.$(O): regs.c compiler.h config.h
-regvals.$(O): regvals.c
+preproc.$(O): preproc.c compiler.h config.h hashtbl.h insnsi.h nasm.h \
+ nasmlib.h pptok.h preproc.h regs.h stdscan.h tables.h tokens.h version.h
+regdis.$(O): regdis.c regs.h
+regflags.$(O): regflags.c compiler.h config.h insnsi.h nasm.h nasmlib.h \
+ regs.h tables.h version.h
+regs.$(O): regs.c compiler.h config.h insnsi.h tables.h
+regvals.$(O): regvals.c compiler.h config.h insnsi.h tables.h
stdscan.$(O): stdscan.c compiler.h config.h insns.h insnsi.h nasm.h \
nasmlib.h regs.h stdscan.h tokens.h version.h
sync.$(O): sync.c compiler.h config.h nasmlib.h sync.h
diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak
index e4b4db2..2824cc6 100644
--- a/Mkfiles/msvc.mak
+++ b/Mkfiles/msvc.mak
@@ -39,11 +39,12 @@ NASM = nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
output/outelf32.$(O) output/outelf64.$(O) \
output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
- preproc.$(O) pptok.$(O) \
- listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O)
+ preproc.$(O) pptok.$(O) macros.$(O) \
+ listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O) \
+ regvals.$(O) regflags.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) \
- insnsd.$(O) insnsb.$(O)
+ insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
all: nasm$(X) ndisasm$(X)
rem cd rdoff && $(MAKE) all
@@ -177,10 +178,10 @@ everything: all doc rdf
# @exclude: "config.h"
#-- Everything below is generated by mkdep.pl - do not edit --#
assemble.$(O): assemble.c assemble.h compiler.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regflags.c regs.h regvals.c tokens.h version.h
+ nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h version.h
crc64.$(O): crc64.c compiler.h
-disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h insnsn.c names.c \
- nasm.h nasmlib.h regdis.c regs.c regs.h sync.h tokens.h version.h
+disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h nasm.h nasmlib.h \
+ regdis.h regs.h sync.h tables.h tokens.h version.h
eval.$(O): eval.c compiler.h eval.h float.h insnsi.h labels.h nasm.h \
nasmlib.h regs.h version.h
exprlib.$(O): exprlib.c compiler.h insnsi.h nasm.h nasmlib.h regs.h \
@@ -195,15 +196,14 @@ insnsb.$(O): insnsb.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
tokens.h version.h
insnsd.$(O): insnsd.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
tokens.h version.h
-insnsn.$(O): insnsn.c
+insnsn.$(O): insnsn.c compiler.h insnsi.h tables.h
labels.$(O): labels.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h regs.h \
version.h
lib/snprintf.$(O): lib/snprintf.c compiler.h nasmlib.h
lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h nasmlib.h
listing.$(O): listing.c compiler.h insnsi.h listing.h nasm.h nasmlib.h \
regs.h version.h
-macros.$(O): macros.c compiler.h
-names.$(O): names.c compiler.h insnsn.c regs.c
+macros.$(O): macros.c compiler.h insnsi.h tables.h
nasm.$(O): nasm.c assemble.h compiler.h eval.h float.h insns.h insnsi.h \
labels.h listing.h nasm.h nasmlib.h outform.h parser.h pptok.h preproc.h \
regs.h stdscan.h tokens.h version.h
@@ -238,14 +238,15 @@ output/outrdf.$(O): output/outrdf.c compiler.h insnsi.h nasm.h nasmlib.h \
output/outrdf2.$(O): output/outrdf2.c compiler.h insnsi.h nasm.h nasmlib.h \
outform.h rdoff/rdoff.h regs.h version.h
parser.$(O): parser.c compiler.h float.h insns.h insnsi.h nasm.h nasmlib.h \
- parser.h regflags.c regs.h stdscan.h tokens.h version.h
+ parser.h regs.h stdscan.h tables.h tokens.h version.h
pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
-preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h macros.c nasm.h \
- nasmlib.h pptok.h preproc.h regs.h stdscan.h tokens.h version.h
-regdis.$(O): regdis.c
-regflags.$(O): regflags.c
-regs.$(O): regs.c compiler.h
-regvals.$(O): regvals.c
+preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
+ pptok.h preproc.h regs.h stdscan.h tables.h tokens.h version.h
+regdis.$(O): regdis.c regs.h
+regflags.$(O): regflags.c compiler.h insnsi.h nasm.h nasmlib.h regs.h \
+ tables.h version.h
+regs.$(O): regs.c compiler.h insnsi.h tables.h
+regvals.$(O): regvals.c compiler.h insnsi.h tables.h
stdscan.$(O): stdscan.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
stdscan.h tokens.h version.h
sync.$(O): sync.c compiler.h nasmlib.h sync.h
diff --git a/Mkfiles/netware.mak b/Mkfiles/netware.mak
index 62c89be..ffbe43c 100644
--- a/Mkfiles/netware.mak
+++ b/Mkfiles/netware.mak
@@ -26,46 +26,24 @@ LDFLAGS+=-Wl,--nlm-kernelspace
LDFLAGS+=-Wl,--nlm-posixflag
LDFLAGS+=-s
-NASM_OBJ = \
- $(OBJDIR)/nasm.o\
- $(OBJDIR)/nasmlib.o\
- $(OBJDIR)/float.o\
- $(OBJDIR)/insnsa.o\
- $(OBJDIR)/insnsb.o\
- $(OBJDIR)/assemble.o\
- $(OBJDIR)/labels.o\
- $(OBJDIR)/hashtbl.o\
- $(OBJDIR)/crc64.o\
- $(OBJDIR)/parser.o\
- $(OBJDIR)/outform.o\
- $(OBJDIR)/outbin.o\
- $(OBJDIR)/outaout.o\
- $(OBJDIR)/outcoff.o\
- $(OBJDIR)/outelf32.o\
- $(OBJDIR)/outelf64.o\
- $(OBJDIR)/outobj.o\
- $(OBJDIR)/outas86.o\
- $(OBJDIR)/outrdf2.o\
- $(OBJDIR)/outdbg.o\
- $(OBJDIR)/outieee.o\
- $(OBJDIR)/outmacho.o\
- $(OBJDIR)/preproc.o\
- $(OBJDIR)/pptok.o\
- $(OBJDIR)/listing.o\
- $(OBJDIR)/eval.o\
- $(OBJDIR)/exprlib.o\
- $(OBJDIR)/stdscan.o\
- $(OBJDIR)/tokhash.o\
- $(EOLIST)
-
-NDIS_OBJ = \
- $(OBJDIR)/ndisasm.o\
- $(OBJDIR)/nasmlib.o\
- $(OBJDIR)/disasm.o\
- $(OBJDIR)/sync.o\
- $(OBJDIR)/insnsd.o\
- $(OBJDIR)/insnsb.o\
- $(EOLIST)
+O = o
+
+NASM = nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
+ assemble.$(O) labels.$(O) hashtbl.$(O) crc64.$(O) parser.$(O) \
+ outform.$(O) output/outbin.$(O) \
+ output/outaout.$(O) output/outcoff.$(O) \
+ output/outelf32.$(O) output/outelf64.$(O) \
+ output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
+ output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
+ preproc.$(O) pptok.$(O) macros.$(O) \
+ listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O) \
+ regvals.$(O) regflags.$(O)
+
+NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) \
+ insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
+
+NASM_OBJ = $(addprefix $(OBJDIR)/,$(notdir $(NASM))) $(EOLIST)
+NDIS_OBJ = $(addprefix $(OBJDIR)/,$(notdir $(NDISASM))) $(EOLIST)
VPATH = *.c $(PROOT) $(PROOT)/output
@@ -140,11 +118,10 @@ $(OBJDIR)/version.inc: $(PROOT)/version $(PROOT)/version.pl $(OBJDIR)
# @continuation: "\"
#-- Everything below is generated by mkdep.pl - do not edit --#
assemble.o: assemble.c assemble.h compiler.h config.h insns.h insnsi.h \
- nasm.h nasmlib.h pptok.h preproc.h regflags.c regs.h regvals.c tokens.h \
- version.h
+ nasm.h nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h version.h
crc64.o: crc64.c compiler.h config.h
-disasm.o: disasm.c compiler.h config.h disasm.h insns.h insnsi.h insnsn.c \
- names.c nasm.h nasmlib.h regdis.c regs.c regs.h sync.h tokens.h version.h
+disasm.o: disasm.c compiler.h config.h disasm.h insns.h insnsi.h nasm.h \
+ nasmlib.h regdis.h regs.h sync.h tables.h tokens.h version.h
eval.o: eval.c compiler.h config.h eval.h float.h insnsi.h labels.h nasm.h \
nasmlib.h regs.h version.h
exprlib.o: exprlib.c compiler.h config.h insnsi.h nasm.h nasmlib.h regs.h \
@@ -159,15 +136,14 @@ insnsb.o: insnsb.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
regs.h tokens.h version.h
insnsd.o: insnsd.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
regs.h tokens.h version.h
-insnsn.o: insnsn.c
+insnsn.o: insnsn.c compiler.h config.h insnsi.h tables.h
labels.o: labels.c compiler.h config.h hashtbl.h insnsi.h nasm.h nasmlib.h \
regs.h version.h
lib/snprintf.o: lib/snprintf.c compiler.h config.h nasmlib.h
lib/vsnprintf.o: lib/vsnprintf.c compiler.h config.h nasmlib.h
listing.o: listing.c compiler.h config.h insnsi.h listing.h nasm.h nasmlib.h \
regs.h version.h
-macros.o: macros.c compiler.h config.h
-names.o: names.c compiler.h config.h insnsn.c regs.c
+macros.o: macros.c compiler.h config.h insnsi.h tables.h
nasm.o: nasm.c assemble.h compiler.h config.h eval.h float.h insns.h \
insnsi.h labels.h listing.h nasm.h nasmlib.h outform.h parser.h pptok.h \
preproc.h regs.h stdscan.h tokens.h version.h
@@ -202,14 +178,15 @@ output/outrdf.o: output/outrdf.c compiler.h config.h insnsi.h nasm.h \
output/outrdf2.o: output/outrdf2.c compiler.h config.h insnsi.h nasm.h \
nasmlib.h outform.h rdoff/rdoff.h regs.h version.h
parser.o: parser.c compiler.h config.h float.h insns.h insnsi.h nasm.h \
- nasmlib.h parser.h regflags.c regs.h stdscan.h tokens.h version.h
+ nasmlib.h parser.h regs.h stdscan.h tables.h tokens.h version.h
pptok.o: pptok.c compiler.h config.h hashtbl.h nasmlib.h pptok.h preproc.h
-preproc.o: preproc.c compiler.h config.h hashtbl.h insnsi.h macros.c nasm.h \
- nasmlib.h pptok.h preproc.h regs.h stdscan.h tokens.h version.h
-regdis.o: regdis.c
-regflags.o: regflags.c
-regs.o: regs.c compiler.h config.h
-regvals.o: regvals.c
+preproc.o: preproc.c compiler.h config.h hashtbl.h insnsi.h nasm.h nasmlib.h \
+ pptok.h preproc.h regs.h stdscan.h tables.h tokens.h version.h
+regdis.o: regdis.c regs.h
+regflags.o: regflags.c compiler.h config.h insnsi.h nasm.h nasmlib.h regs.h \
+ tables.h version.h
+regs.o: regs.c compiler.h config.h insnsi.h tables.h
+regvals.o: regvals.c compiler.h config.h insnsi.h tables.h
stdscan.o: stdscan.c compiler.h config.h insns.h insnsi.h nasm.h nasmlib.h \
regs.h stdscan.h tokens.h version.h
sync.o: sync.c compiler.h config.h nasmlib.h sync.h
diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak
index 5168e90..205a7be 100644
--- a/Mkfiles/openwcom.mak
+++ b/Mkfiles/openwcom.mak
@@ -51,11 +51,12 @@ NASM = nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) &
output\outelf32.$(O) output\outelf64.$(O) &
output\outobj.$(O) output\outas86.$(O) output\outrdf2.$(O) &
output\outdbg.$(O) output\outieee.$(O) output\outmacho.$(O) &
- preproc.$(O) pptok.$(O) &
- listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O)
+ preproc.$(O) pptok.$(O) macros.$(O) &
+ listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O) &
+ regvals.$(O) regflags.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) &
- insnsd.$(O) insnsb.$(O)
+ insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
what: .SYMBOLIC
@echo Please build "dos", "win32" or "os2"
@@ -117,6 +118,8 @@ regflags.c: regs.dat regs.pl
$(PERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c
regdis.c: regs.dat regs.pl
$(PERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c
+regdis.h: regs.dat regs.pl
+ $(PERL) $(srcdir)/regs.pl dh $(srcdir)/regs.dat > regdis.h
regvals.c: regs.dat regs.pl
$(PERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c
regs.h: regs.dat regs.pl
@@ -140,9 +143,10 @@ pptok.c: pptok.dat pptok.pl perllib/phash.ph
# This target generates all files that require perl.
# This allows easier generation of distribution (see dist target).
-PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c &
- regs.c regs.h regflags.c regdis.c regvals.c tokhash.c tokens.h &
- version.h version.mac pptok.h pptok.c
+PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
+ regs.c regs.h regflags.c regdis.c regdis.h regvals.c \
+ tokhash.c tokens.h pptok.h pptok.c \
+ version.h version.mac
perlreq: $(PERLREQ)
clean: .SYMBOLIC
@@ -203,10 +207,10 @@ everything: all doc rdf
# @continuation: "&"
#-- Everything below is generated by mkdep.pl - do not edit --#
assemble.$(O): assemble.c assemble.h compiler.h insns.h insnsi.h nasm.h &
- nasmlib.h pptok.h preproc.h regflags.c regs.h regvals.c tokens.h version.h
+ nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h version.h
crc64.$(O): crc64.c compiler.h
-disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h insnsn.c names.c &
- nasm.h nasmlib.h regdis.c regs.c regs.h sync.h tokens.h version.h
+disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h nasm.h nasmlib.h &
+ regdis.h regs.h sync.h tables.h tokens.h version.h
eval.$(O): eval.c compiler.h eval.h float.h insnsi.h labels.h nasm.h &
nasmlib.h regs.h version.h
exprlib.$(O): exprlib.c compiler.h insnsi.h nasm.h nasmlib.h regs.h &
@@ -221,15 +225,14 @@ insnsb.$(O): insnsb.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h &
tokens.h version.h
insnsd.$(O): insnsd.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h &
tokens.h version.h
-insnsn.$(O): insnsn.c
+insnsn.$(O): insnsn.c compiler.h insnsi.h tables.h
labels.$(O): labels.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h regs.h &
version.h
lib\snprintf.$(O): lib\snprintf.c compiler.h nasmlib.h
lib\vsnprintf.$(O): lib\vsnprintf.c compiler.h nasmlib.h
listing.$(O): listing.c compiler.h insnsi.h listing.h nasm.h nasmlib.h &
regs.h version.h
-macros.$(O): macros.c compiler.h
-names.$(O): names.c compiler.h insnsn.c regs.c
+macros.$(O): macros.c compiler.h insnsi.h tables.h
nasm.$(O): nasm.c assemble.h compiler.h eval.h float.h insns.h insnsi.h &
labels.h listing.h nasm.h nasmlib.h outform.h parser.h pptok.h preproc.h &
regs.h stdscan.h tokens.h version.h
@@ -264,14 +267,15 @@ output\outrdf.$(O): output\outrdf.c compiler.h insnsi.h nasm.h nasmlib.h &
output\outrdf2.$(O): output\outrdf2.c compiler.h insnsi.h nasm.h nasmlib.h &
outform.h rdoff\rdoff.h regs.h version.h
parser.$(O): parser.c compiler.h float.h insns.h insnsi.h nasm.h nasmlib.h &
- parser.h regflags.c regs.h stdscan.h tokens.h version.h
+ parser.h regs.h stdscan.h tables.h tokens.h version.h
pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
-preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h macros.c nasm.h &
- nasmlib.h pptok.h preproc.h regs.h stdscan.h tokens.h version.h
-regdis.$(O): regdis.c
-regflags.$(O): regflags.c
-regs.$(O): regs.c compiler.h
-regvals.$(O): regvals.c
+preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h &
+ pptok.h preproc.h regs.h stdscan.h tables.h tokens.h version.h
+regdis.$(O): regdis.c regs.h
+regflags.$(O): regflags.c compiler.h insnsi.h nasm.h nasmlib.h regs.h &
+ tables.h version.h
+regs.$(O): regs.c compiler.h insnsi.h tables.h
+regvals.$(O): regvals.c compiler.h insnsi.h tables.h
stdscan.$(O): stdscan.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h &
stdscan.h tokens.h version.h
sync.$(O): sync.c compiler.h nasmlib.h sync.h
diff --git a/Mkfiles/owlinux.mak b/Mkfiles/owlinux.mak
index 1306bad..69b4c40 100644
--- a/Mkfiles/owlinux.mak
+++ b/Mkfiles/owlinux.mak
@@ -62,11 +62,12 @@ NASM = nasm.$(O) nasmlib.$(O) float.$(O) insnsa.$(O) insnsb.$(O) \
output/outelf32.$(O) output/outelf64.$(O) \
output/outobj.$(O) output/outas86.$(O) output/outrdf2.$(O) \
output/outdbg.$(O) output/outieee.$(O) output/outmacho.$(O) \
- preproc.$(O) pptok.$(O) \
- listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O)
+ preproc.$(O) pptok.$(O) macros.$(O) \
+ listing.$(O) eval.$(O) exprlib.$(O) stdscan.$(O) tokhash.$(O) \
+ regvals.$(O) regflags.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) \
- insnsd.$(O) insnsb.$(O)
+ insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O)
what:
@echo 'Please build "dos", "win32" or "os2"'
@@ -127,6 +128,8 @@ regflags.c: regs.dat regs.pl
$(PERL) $(srcdir)/regs.pl fc $(srcdir)/regs.dat > regflags.c
regdis.c: regs.dat regs.pl
$(PERL) $(srcdir)/regs.pl dc $(srcdir)/regs.dat > regdis.c
+regdis.h: regs.dat regs.pl
+ $(PERL) $(srcdir)/regs.pl dh $(srcdir)/regs.dat > regdis.h
regvals.c: regs.dat regs.pl
$(PERL) $(srcdir)/regs.pl vc $(srcdir)/regs.dat > regvals.c
regs.h: regs.dat regs.pl
@@ -151,8 +154,9 @@ pptok.c: pptok.dat pptok.pl perllib/phash.ph
# This target generates all files that require perl.
# This allows easier generation of distribution (see dist target).
PERLREQ = macros.c insnsb.c insnsa.c insnsd.c insnsi.h insnsn.c \
- regs.c regs.h regflags.c regdis.c regvals.c tokhash.c tokens.h \
- version.h version.mac pptok.h pptok.c
+ regs.c regs.h regflags.c regdis.c regdis.h regvals.c \
+ tokhash.c tokens.h pptok.h pptok.c \
+ version.h version.mac
perlreq: $(PERLREQ)
clean:
@@ -213,10 +217,10 @@ everything: all doc rdf
# @continuation: "\"
#-- Everything below is generated by mkdep.pl - do not edit --#
assemble.$(O): assemble.c assemble.h compiler.h insns.h insnsi.h nasm.h \
- nasmlib.h pptok.h preproc.h regflags.c regs.h regvals.c tokens.h version.h
+ nasmlib.h pptok.h preproc.h regs.h tables.h tokens.h version.h
crc64.$(O): crc64.c compiler.h
-disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h insnsn.c names.c \
- nasm.h nasmlib.h regdis.c regs.c regs.h sync.h tokens.h version.h
+disasm.$(O): disasm.c compiler.h disasm.h insns.h insnsi.h nasm.h nasmlib.h \
+ regdis.h regs.h sync.h tables.h tokens.h version.h
eval.$(O): eval.c compiler.h eval.h float.h insnsi.h labels.h nasm.h \
nasmlib.h regs.h version.h
exprlib.$(O): exprlib.c compiler.h insnsi.h nasm.h nasmlib.h regs.h \
@@ -231,15 +235,14 @@ insnsb.$(O): insnsb.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
tokens.h version.h
insnsd.$(O): insnsd.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
tokens.h version.h
-insnsn.$(O): insnsn.c
+insnsn.$(O): insnsn.c compiler.h insnsi.h tables.h
labels.$(O): labels.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h regs.h \
version.h
lib/snprintf.$(O): lib/snprintf.c compiler.h nasmlib.h
lib/vsnprintf.$(O): lib/vsnprintf.c compiler.h nasmlib.h
listing.$(O): listing.c compiler.h insnsi.h listing.h nasm.h nasmlib.h \
regs.h version.h
-macros.$(O): macros.c compiler.h
-names.$(O): names.c compiler.h insnsn.c regs.c
+macros.$(O): macros.c compiler.h insnsi.h tables.h
nasm.$(O): nasm.c assemble.h compiler.h eval.h float.h insns.h insnsi.h \
labels.h listing.h nasm.h nasmlib.h outform.h parser.h pptok.h preproc.h \
regs.h stdscan.h tokens.h version.h
@@ -274,14 +277,15 @@ output/outrdf.$(O): output/outrdf.c compiler.h insnsi.h nasm.h nasmlib.h \
output/outrdf2.$(O): output/outrdf2.c compiler.h insnsi.h nasm.h nasmlib.h \
outform.h rdoff/rdoff.h regs.h version.h
parser.$(O): parser.c compiler.h float.h insns.h insnsi.h nasm.h nasmlib.h \
- parser.h regflags.c regs.h stdscan.h tokens.h version.h
+ parser.h regs.h stdscan.h tables.h tokens.h version.h
pptok.$(O): pptok.c compiler.h hashtbl.h nasmlib.h pptok.h preproc.h
-preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h macros.c nasm.h \
- nasmlib.h pptok.h preproc.h regs.h stdscan.h tokens.h version.h
-regdis.$(O): regdis.c
-regflags.$(O): regflags.c
-regs.$(O): regs.c compiler.h
-regvals.$(O): regvals.c
+preproc.$(O): preproc.c compiler.h hashtbl.h insnsi.h nasm.h nasmlib.h \
+ pptok.h preproc.h regs.h stdscan.h tables.h tokens.h version.h
+regdis.$(O): regdis.c regs.h
+regflags.$(O): regflags.c compiler.h insnsi.h nasm.h nasmlib.h regs.h \
+ tables.h version.h
+regs.$(O): regs.c compiler.h insnsi.h tables.h
+regvals.$(O): regvals.c compiler.h insnsi.h tables.h
stdscan.$(O): stdscan.c compiler.h insns.h insnsi.h nasm.h nasmlib.h regs.h \
stdscan.h tokens.h version.h
sync.$(O): sync.c compiler.h nasmlib.h sync.h
diff --git a/assemble.c b/assemble.c
index 63ac21e..0397f5d 100644
--- a/assemble.c
+++ b/assemble.c
@@ -116,8 +116,7 @@
#include "assemble.h"
#include "insns.h"
#include "preproc.h"
-#include "regflags.c"
-#include "regvals.c"
+#include "tables.h"
/* Initialized to zero by the C standard */
static const uint8_t const_zero_buf[256];
@@ -1123,7 +1122,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits,
if (c <= 0177) {
/* pick rfield from operand b */
rflags = regflag(&ins->oprs[c & 7]);
- rfield = regvals[ins->oprs[c & 7].basereg];
+ rfield = nasm_regvals[ins->oprs[c & 7].basereg];
} else {
rflags = 0;
rfield = c & 7;
@@ -1585,7 +1584,7 @@ static void gencode(int32_t segment, int64_t offset, int bits,
case 0172:
c = *codes++;
opx = &ins->oprs[c >> 3];
- bytes[0] = regvals[opx->basereg] << 4;
+ bytes[0] = nasm_regvals[opx->basereg] << 4;
opx = &ins->oprs[c & 7];
if (opx->segment != NO_SEG || opx->wrt != NO_SEG) {
errfunc(ERR_NONFATAL,
@@ -1605,7 +1604,7 @@ static void gencode(int32_t segment, int64_t offset, int bits,
case 0173:
c = *codes++;
opx = &ins->oprs[c >> 4];
- bytes[0] = regvals[opx->basereg] << 4;
+ bytes[0] = nasm_regvals[opx->basereg] << 4;
bytes[0] |= c & 15;
out(offset, segment, bytes, OUT_RAWDATA, 1, NO_SEG, NO_SEG);
offset++;
@@ -1803,7 +1802,7 @@ static void gencode(int32_t segment, int64_t offset, int bits,
if (c <= 0177) {
/* pick rfield from operand b */
rflags = regflag(&ins->oprs[c & 7]);
- rfield = regvals[ins->oprs[c & 7].basereg];
+ rfield = nasm_regvals[ins->oprs[c & 7].basereg];
} else {
/* rfield is constant */
rflags = 0;
@@ -1877,7 +1876,7 @@ static int32_t regflag(const operand * o)
if (o->basereg < EXPR_REG_START || o->basereg >= REG_ENUM_LIMIT) {
errfunc(ERR_PANIC, "invalid operand passed to regflag()");
}
- return reg_flags[o->basereg];
+ return nasm_reg_flags[o->basereg];
}
static int32_t regval(const operand * o)
@@ -1885,7 +1884,7 @@ static int32_t regval(const operand * o)
if (o->basereg < EXPR_REG_START || o->basereg >= REG_ENUM_LIMIT) {
errfunc(ERR_PANIC, "invalid operand passed to regval()");
}
- return regvals[o->basereg];
+ return nasm_regvals[o->basereg];
}
static int op_rexflags(const operand * o, int mask)
@@ -1897,8 +1896,8 @@ static int op_rexflags(const operand * o, int mask)
errfunc(ERR_PANIC, "invalid operand passed to op_rexflags()");
}
- flags = reg_flags[o->basereg];
- val = regvals[o->basereg];
+ flags = nasm_reg_flags[o->basereg];
+ val = nasm_regvals[o->basereg];
return rexflags(val, flags, mask);
}
@@ -2113,7 +2112,7 @@ static ea *process_ea(operand * input, ea * output, int bits,
|| input->basereg >= REG_ENUM_LIMIT)
return NULL;
f = regflag(input);
- i = regvals[input->basereg];
+ i = nasm_regvals[input->basereg];
if (REG_EA & ~f)
return NULL; /* Invalid EA register */
@@ -2155,16 +2154,16 @@ static ea *process_ea(operand * input, ea * output, int bits,
i = -1; /* make this easy, at least */
if (i >= EXPR_REG_START && i < REG_ENUM_LIMIT) {
- it = regvals[i];
- ix = reg_flags[i];
+ it = nasm_regvals[i];
+ ix = nasm_reg_flags[i];
} else {
it = -1;
ix = 0;
}
if (b >= EXPR_REG_START && b < REG_ENUM_LIMIT) {
- bt = regvals[b];
- bx = reg_flags[b];
+ bt = nasm_regvals[b];
+ bx = nasm_reg_flags[b];
} else {
bt = -1;
bx = 0;
@@ -2437,14 +2436,14 @@ static void add_asp(insn *ins, int addrbits)
|| ins->oprs[j].indexreg >= REG_ENUM_LIMIT)
i = 0;
else
- i = reg_flags[ins->oprs[j].indexreg];
+ i = nasm_reg_flags[ins->oprs[j].indexreg];
/* Verify as Register */
if (ins->oprs[j].basereg < EXPR_REG_START
|| ins->oprs[j].basereg >= REG_ENUM_LIMIT)
b = 0;
else
- b = reg_flags[ins->oprs[j].basereg];
+ b = nasm_reg_flags[ins->oprs[j].basereg];
if (ins->oprs[j].scale == 0)
i = 0;
diff --git a/disasm.c b/disasm.c
index 2d93ea6..5cdb0ec 100644
--- a/disasm.c
+++ b/disasm.c
@@ -19,8 +19,8 @@
#include "disasm.h"
#include "sync.h"
#include "insns.h"
-
-#include "names.c"
+#include "tables.h"
+#include "regdis.h"
/*
* Flags that go into the `segment' field of `insn' structures
@@ -36,8 +36,6 @@
#define SEG_SIGNED 128
#define SEG_64BIT 256
-#include "regdis.c"
-
/*
* Prefix information
*/
@@ -120,11 +118,11 @@ static enum reg_enum whichreg(int32_t regflags, int regval, int rex)
return (regval == 1) ? R_CS : 0;
if (!(REG_DESS & ~regflags))
return (regval == 0 || regval == 2
- || regval == 3 ? rd_sreg[regval] : 0);
+ || regval == 3 ? nasm_rd_sreg[regval] : 0);
if (!(REG_FSGS & ~regflags))
- return (regval == 4 || regval == 5 ? rd_sreg[regval] : 0);
+ return (regval == 4 || regval == 5 ? nasm_rd_sreg[regval] : 0);
if (!(REG_SEG67 & ~regflags))
- return (regval == 6 || regval == 7 ? rd_sreg[regval] : 0);
+ return (regval == 6 || regval == 7 ? nasm_rd_sreg[regval] : 0);
/* All the entries below look up regval in an 16-entry array */
if (regval < 0 || regval > 15)
@@ -132,48 +130,39 @@ static enum reg_enum whichreg(int32_t regflags, int regval, int rex)
if (!(REG8 & ~regflags)) {
if (rex & REX_P)
- return rd_reg8_rex[regval];
+ return nasm_rd_reg8_rex[regval];
else
- return rd_reg8[regval];
+ return nasm_rd_reg8[regval];
}
if (!(REG16 & ~regflags))
- return rd_reg16[regval];
+ return nasm_rd_reg16[regval];
if (!(REG32 & ~regflags))
- return rd_reg32[regval];
+ return nasm_rd_reg32[regval];
if (!(REG64 & ~regflags))
- return rd_reg64[regval];
+ return nasm_rd_reg64[regval];
if (!(REG_SREG & ~regflags))
- return rd_sreg[regval & 7]; /* Ignore REX */
+ return nasm_rd_sreg[regval & 7]; /* Ignore REX */
if (!(REG_CREG & ~regflags))
- return rd_creg[regval];
+ return nasm_rd_creg[regval];
if (!(REG_DREG & ~regflags))
- return rd_dreg[regval];
+ return nasm_rd_dreg[regval];
if (!(REG_TREG & ~regflags)) {
if (rex & REX_P)
return 0; /* TR registers are ill-defined with rex */
- return rd_treg[regval];
+ return nasm_rd_treg[regval];
}
if (!(FPUREG & ~regflags))
- return rd_fpureg[regval & 7]; /* Ignore REX */
+ return nasm_rd_fpureg[regval & 7]; /* Ignore REX */
if (!(MMXREG & ~regflags))
- return rd_mmxreg[regval & 7]; /* Ignore REX */
+ return nasm_rd_mmxreg[regval & 7]; /* Ignore REX */
if (!(XMMREG & ~regflags))
- return rd_xmmreg[regval];
+ return nasm_rd_xmmreg[regval];
if (!(YMMREG & ~regflags))
- return rd_ymmreg[regval];
+ return nasm_rd_ymmreg[regval];
return 0;
}
-static const char *whichcond(int condval)
-{
- static int conds[] = {
- C_O, C_NO, C_C, C_NC, C_Z, C_NZ, C_NA, C_A,
- C_S, C_NS, C_PE, C_PO, C_L, C_NL, C_NG, C_G
- };
- return conditions[conds[condval]];
-}
-
/*
* Process a DREX suffix
*/
@@ -301,9 +290,9 @@ static uint8_t *do_ea(uint8_t *data, int modrm, int asize,
op->indexreg = -1;
if (a64)
- op->basereg = rd_reg64[rm | ((rex & REX_B) ? 8 : 0)];
+ op->basereg = nasm_rd_reg64[rm | ((rex & REX_B) ? 8 : 0)];
else
- op->basereg = rd_reg32[rm | ((rex & REX_B) ? 8 : 0)];
+ op->basereg = nasm_rd_reg32[rm | ((rex & REX_B) ? 8 : 0)];
if (rm == 5 && mod == 0) {
if (segsize == 64) {
@@ -329,17 +318,17 @@ static uint8_t *do_ea(uint8_t *data, int modrm, int asize,
if (index == 4)
op->indexreg = -1; /* ESP/RSP/R12 cannot be an index */
else if (a64)
- op->indexreg = rd_reg64[index | ((rex & REX_X) ? 8 : 0)];
+ op->indexreg = nasm_rd_reg64[index | ((rex & REX_X) ? 8 : 0)];
else
- op->indexreg = rd_reg32[index | ((rex & REX_X) ? 8 : 0)];
+ op->indexreg = nasm_rd_reg32[index | ((rex & REX_X) ? 8 : 0)];
if (base == 5 && mod == 0) {
op->basereg = -1;
mod = 2; /* Fake disp32 */
} else if (a64)
- op->basereg = rd_reg64[base | ((rex & REX_B) ? 8 : 0)];
+ op->basereg = nasm_rd_reg64[base | ((rex & REX_B) ? 8 : 0)];
else
- op->basereg = rd_reg32[base | ((rex & REX_B) ? 8 : 0)];
+ op->basereg = nasm_rd_reg32[base | ((rex & REX_B) ? 8 : 0)];
if (segsize == 16)
op->disp_size = 32;
@@ -975,6 +964,12 @@ static int matches(const struct itemplate *t, uint8_t *data,
return data - origdata;
}
+/* Condition names for disassembly, sorted by x86 code */
+static const char * const condition_name[16] = {
+ "o", "no", "c", "nc", "z", "nz", "na", "a",
+ "s", "ns", "pe", "po", "l", "nl", "ng", "g"
+};
+
int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
int32_t offset, int autosync, uint32_t prefer)
{
@@ -1213,17 +1208,18 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
break;
}
- for (i = 0; i < (int)elements(ico); i++)
- if ((*p)->opcode == ico[i]) {
+ for (i = 0; i < NCOND_OPCODES; i++)
+ if ((*p)->opcode == nasm_cond_insn_opcodes[i]) {
slen +=
- snprintf(output + slen, outbufsize - slen, "%s%s", icn[i],
- whichcond(ins.condition));
+ snprintf(output + slen, outbufsize - slen, "%s%s",
+ nasm_cond_insn_names[i],
+ condition_name[ins.condition]);
break;
}
- if (i >= (int)elements(ico))
+ if (i >= NCOND_OPCODES)
slen +=
snprintf(output + slen, outbufsize - slen, "%s",
- insn_names[(*p)->opcode]);
+ nasm_insn_names[(*p)->opcode]);
colon = false;
length += data - origdata; /* fix up for prefixes */
for (i = 0; i < (*p)->operands; i++) {
@@ -1268,7 +1264,7 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
if (t & TO)
slen += snprintf(output + slen, outbufsize - slen, "to ");
slen += snprintf(output + slen, outbufsize - slen, "%s",
- reg_names[reg - EXPR_REG_START]);
+ nasm_reg_names[reg-EXPR_REG_START]);
} else if (!(UNITY & ~t)) {
output[slen++] = '1';
} else if (t & IMMEDIATE) {
@@ -1356,16 +1352,14 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
}
if (o->basereg != -1) {
slen += snprintf(output + slen, outbufsize - slen, "%s",
- reg_names[(o->basereg -
- EXPR_REG_START)]);
+ nasm_reg_names[(o->basereg-EXPR_REG_START)]);
started = true;
}
if (o->indexreg != -1) {
if (started)
output[slen++] = '+';
slen += snprintf(output + slen, outbufsize - slen, "%s",
- reg_names[(o->indexreg -
- EXPR_REG_START)]);
+ nasm_reg_names[(o->indexreg-EXPR_REG_START)]);
if (o->scale > 1)
slen +=
snprintf(output + slen, outbufsize - slen, "*%d",
diff --git a/insns.pl b/insns.pl
index 280b8b2..b5e49f1 100644
--- a/insns.pl
+++ b/insns.pl
@@ -231,6 +231,7 @@ if ( !defined($output) || $output eq 'i' ) {
print I "\tI_none = -1\n";
print I "\n};\n\n";
print I "#define MAX_INSLEN ", $maxlen, "\n\n";
+ print I "#define NCOND_OPCODES ", scalar @opcodes_cc, "\n\n";
print I "#endif /* NASM_INSNSI_H */\n";
close I;
@@ -243,9 +244,9 @@ if ( !defined($output) || $output eq 'n' ) {
print N "/* This file is auto-generated from insns.dat by insns.pl" .
" - don't edit it */\n\n";
- print N "/* This file in included by names.c */\n\n";
+ print N "#include \"tables.h\"\n\n";
- print N "static const char * const insn_names[] = {";
+ print N "const char * const nasm_insn_names[] = {";
$first = 1;
foreach $i (@opcodes) {
print N "," if ( !$first );
@@ -256,7 +257,7 @@ if ( !defined($output) || $output eq 'n' ) {
}
print N "\n};\n\n";
print N "/* Conditional instructions */\n";
- print N "static const char *icn[] = {";
+ print N "const char * const nasm_cond_insn_names[] = {";
$first = 1;
foreach $i (@opcodes_cc) {
print N "," if ( !$first );
@@ -269,7 +270,7 @@ if ( !defined($output) || $output eq 'n' ) {
print N "\n};\n\n";
print N "/* and the corresponding opcodes */\n";
- print N "static const enum opcode ico[] = {";
+ print N "const enum opcode nasm_cond_insn_opcodes[] = {";
$first = 1;
foreach $i (@opcodes_cc) {
print N "," if ( !$first );
@@ -278,7 +279,6 @@ if ( !defined($output) || $output eq 'n' ) {
}
print N "\n};\n";
-
close N;
}
diff --git a/macros.pl b/macros.pl
index e4f60a4..98f97ee 100644
--- a/macros.pl
+++ b/macros.pl
@@ -21,9 +21,9 @@ open(OUTPUT,">macros.c") or die "unable to open macros.c\n";
print OUTPUT "/* This file auto-generated from standard.mac by macros.pl" .
" - don't edit it */\n";
print OUTPUT "\n";
-print OUTPUT "#include \"compiler.h\"\n";
+print OUTPUT "#include \"tables.h\"\n";
print OUTPUT "\n";
-print OUTPUT "static const char * const stdmac[] = {\n";
+print OUTPUT "const char * const nasm_stdmac[] = {\n";
foreach $fname ( @ARGV ) {
open(INPUT,$fname) or die "unable to open $fname\n";
@@ -46,7 +46,8 @@ foreach $fname ( @ARGV ) {
}
close(INPUT);
}
-print OUTPUT " NULL\n};\n";
+print OUTPUT " NULL\n};\n\n";
$tasm_count = $index unless ( defined($tasm_count) );
-print OUTPUT "#define TASM_MACRO_COUNT $tasm_count\n";
+print OUTPUT "const char * const * nasm_stdmac_after_tasm = ",
+ "&nasm_stdmac[$tasm_count];\n";
close(OUTPUT);
diff --git a/names.c b/names.c
deleted file mode 100644
index 0394d69..0000000
--- a/names.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* names.c included source file defining instruction and register
- * names for the Netwide [Dis]Assembler
- *
- * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
- * Julian Hall. All rights reserved. The software is
- * redistributable under the license given in the file "LICENSE"
- * distributed in the NASM archive.
- */
-
-static const char *conditions[] = { /* condition code names */
- "a", "ae", "b", "be", "c", "e", "g", "ge", "l", "le", "na", "nae",
- "nb", "nbe", "nc", "ne", "ng", "nge", "nl", "nle", "no", "np",
- "ns", "nz", "o", "p", "pe", "po", "s", "z"
-};
-
-/* Register names automatically generated from regs.dat */
-#include "regs.c"
-
-/* Instruction names automatically generated from insns.dat */
-#include "insnsn.c"
diff --git a/parser.c b/parser.c
index 72e4e6c..c513349 100644
--- a/parser.c
+++ b/parser.c
@@ -23,13 +23,12 @@
#include "stdscan.h"
#include "parser.h"
#include "float.h"
+#include "tables.h"
extern int in_abs_seg; /* ABSOLUTE segment flag */
extern int32_t abs_seg; /* ABSOLUTE segment */
extern int32_t abs_offset; /* ABSOLUTE segment offset */
-#include "regflags.c" /* List of register flags */
-
static int is_comma_next(void);
static int i;
@@ -192,7 +191,7 @@ restart_parse:
return result;
}
if (i != TOKEN_ID && i != TOKEN_INSN && i != TOKEN_PREFIX &&
- (i != TOKEN_REG || (REG_SREG & ~reg_flags[tokval.t_integer]))) {
+ (i != TOKEN_REG || (REG_SREG & ~nasm_reg_flags[tokval.t_integer]))) {
error(ERR_NONFATAL, "label or instruction expected"
" at start of line");
result->opcode = -1;
@@ -233,7 +232,7 @@ restart_parse:
result->times = 1L;
while (i == TOKEN_PREFIX ||
- (i == TOKEN_REG && !(REG_SREG & ~reg_flags[tokval.t_integer])))
+ (i == TOKEN_REG && !(REG_SREG & ~nasm_reg_flags[tokval.t_integer])))
{
first = false;
@@ -621,14 +620,14 @@ restart_parse:
* Process the segment override.
*/
if (value[1].type != 0 || value->value != 1 ||
- REG_SREG & ~reg_flags[value->type])
+ REG_SREG & ~nasm_reg_flags[value->type])
error(ERR_NONFATAL, "invalid segment override");
else if (result->prefixes[PPS_SEG])
error(ERR_NONFATAL,
"instruction has conflicting segment overrides");
else {
result->prefixes[PPS_SEG] = value->type;
- if (!(REG_FSGS & ~reg_flags[value->type]))
+ if (!(REG_FSGS & ~nasm_reg_flags[value->type]))
result->oprs[operand].eaflags |= EAF_FSGS;
}
@@ -846,7 +845,7 @@ restart_parse:
result->oprs[operand].type &= TO;
result->oprs[operand].type |= REGISTER;
- result->oprs[operand].type |= reg_flags[value->type];
+ result->oprs[operand].type |= nasm_reg_flags[value->type];
result->oprs[operand].basereg = value->type;
if (rs && (result->oprs[operand].type & SIZE_MASK) != rs)
diff --git a/preproc.c b/preproc.c
index 9e97257..0560beb 100644
--- a/preproc.c
+++ b/preproc.c
@@ -50,6 +50,7 @@
#include "hashtbl.h"
#include "stdscan.h"
#include "tokens.h"
+#include "tables.h"
typedef struct SMacro SMacro;
typedef struct MMacro MMacro;
@@ -352,10 +353,9 @@ static MMacro *defining;
#define PARAM_DELTA 16
/*
- * The standard macro set: defined as `static char *stdmac[]'. Also
- * gives our position in the macro set, when we're processing it.
+ * The standard macro set: defined in macros.c in the array nasm_stdmac.
+ * This gives our position in the macro set, when we're processing it.
*/
-#include "macros.c"
static const char * const *stdmacpos;
/*
@@ -3723,9 +3723,9 @@ pp_reset(char *file, int apass, efunc errfunc, evalfunc eval,
init_macros();
unique = 0;
if (tasm_compatible_mode) {
- stdmacpos = stdmac;
+ stdmacpos = nasm_stdmac;
} else {
- stdmacpos = &stdmac[TASM_MACRO_COUNT];
+ stdmacpos = nasm_stdmac_after_tasm;
}
any_extrastdmac = (extrastdmac != NULL);
list = listgen;
diff --git a/regs.pl b/regs.pl
index 3ba802c..d4e3996 100755
--- a/regs.pl
+++ b/regs.pl
@@ -102,8 +102,8 @@ if ( $fmt eq 'h' ) {
} elsif ( $fmt eq 'c' ) {
# Output regs.c
print "/* automatically generated from $file - do not edit */\n\n";
- print "#include \"compiler.h\"\n\n";
- print "static const char * const reg_names[] = "; $ch = '{';
+ print "#include \"tables.h\"\n\n";
+ print "const char * const nasm_reg_names[] = "; $ch = '{';
# This one has no dummy entry for 0
foreach $reg ( sort(keys(%regs)) ) {
print "$ch\n \"${reg}\"";
@@ -112,8 +112,10 @@ if ( $fmt eq 'h' ) {
print "\n};\n";
} elsif ( $fmt eq 'fc' ) {
# Output regflags.c
- print "/* automatically generated from $file - do not edit */\n";
- print "static const int32_t reg_flags[] = {\n";
+ print "/* automatically generated from $file - do not edit */\n\n";
+ print "#include \"tables.h\"\n";
+ print "#include \"nasm.h\"\n\n";
+ print "const int32_t nasm_reg_flags[] = {\n";
print " 0"; # Dummy entry for 0
foreach $reg ( sort(keys(%regs)) ) {
print ",\n ", $regs{$reg}; # Print the class of the register
@@ -121,8 +123,9 @@ if ( $fmt eq 'h' ) {
print "\n};\n";
} elsif ( $fmt eq 'vc' ) {
# Output regvals.c
- print "/* automatically generated from $file - do not edit */\n";
- print "static const int regvals[] = {\n";
+ print "/* automatically generated from $file - do not edit */\n\n";
+ print "#include \"tables.h\"\n\n";
+ print "const int nasm_regvals[] = {\n";
print " -1"; # Dummy entry for 0
foreach $reg ( sort(keys(%regs)) ) {
printf ",\n %2d", $regvals{$reg}; # Print the regval of the register
@@ -130,9 +133,11 @@ if ( $fmt eq 'h' ) {
print "\n};\n";
} elsif ( $fmt eq 'dc' ) {
# Output regdis.c
- print "/* automatically generated from $file - do not edit */\n";
+ print "/* automatically generated from $file - do not edit */\n\n";
+ print "#include \"regs.h\"\n\n";
foreach $class ( sort(keys(%disclass)) ) {
- printf "static const enum reg_enum rd_%-8s[] = {", $class;
+ printf "const enum reg_enum nasm_rd_%-8s[%d] = {\n",
+ $class, scalar @{$disclass{$class}};
@foo = @{$disclass{$class}};
@bar = ();
for ( $i = 0 ; $i < scalar(@foo) ; $i++ ) {
@@ -144,6 +149,13 @@ if ( $fmt eq 'h' ) {
}
print join(',', @bar), "};\n";
}
+} elsif ( $fmt eq 'dh' ) {
+ # Output regdis.h
+ print "/* automatically generated from $file - do not edit */\n";
+ foreach $class ( sort(keys(%disclass)) ) {
+ printf "const enum reg_enum nasm_rd_%-8s[%d];\n",
+ $class, scalar @{$disclass{$class}};
+ }
} else {
die "$0: Unknown output format\n";
}
diff --git a/tables.h b/tables.h
new file mode 100644
index 0000000..9945798
--- /dev/null
+++ b/tables.h
@@ -0,0 +1,36 @@
+/*
+ * tables.h
+ *
+ * Declarations for auto-generated tables
+ */
+
+#ifndef TABLES_H
+#define TABLES_H
+
+#include "compiler.h"
+#include <inttypes.h>
+#include "insnsi.h" /* For enum opcode */
+
+/* --- From standard.mac via macros.pl: --- */
+
+/* macros.c */
+extern const char * const nasm_stdmac[];
+extern const char * const * nasm_stdmac_after_tasm;
+
+/* --- From insns.dat via insns.pl: --- */
+
+/* insnsn.c */
+extern const char * const nasm_insn_names[];
+extern const char * const nasm_cond_insn_names[];
+extern const enum opcode nasm_cond_insn_opcodes[];
+
+/* --- From regs.dat via regs.pl: --- */
+
+/* regs.c */
+extern const char * const nasm_reg_names[];
+/* regflags.c */
+extern const int32_t nasm_reg_flags[];
+/* regvals.c */
+extern const int nasm_regvals[];
+
+#endif /* TABLES_H */