fixup commit for tag 'distr2'
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -12,7 +12,6 @@ csb.s
|
||||
dup.s
|
||||
dvi2.s
|
||||
exg.s
|
||||
flp.s
|
||||
inn.s
|
||||
ior.s
|
||||
lar2.s
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
.define .adf4,.adf8,.sbf4,.sbf8,.mlf4,.mlf8,.dvf4,.dvf8
|
||||
.define .ngf4,.ngf8,.fif4,.fif8,.fef4,.fef8
|
||||
.define .zrf4,.zrf8
|
||||
.define .cfi,.cif,.cuf,.cff,.cfu
|
||||
.define .cmf4,.cmf8
|
||||
|
||||
! Floating point is not implemented
|
||||
|
||||
.adf4:
|
||||
.adf8:
|
||||
.sbf4:
|
||||
.sbf8:
|
||||
.mlf4:
|
||||
.mlf8:
|
||||
.dvf4:
|
||||
.dvf8:
|
||||
.ngf4:
|
||||
.ngf8:
|
||||
.fif4:
|
||||
.fif8:
|
||||
.fef4:
|
||||
.fef8:
|
||||
.zrf4:
|
||||
.zrf8:
|
||||
.cfi:
|
||||
.cif:
|
||||
.cuf:
|
||||
.cff:
|
||||
.cfu:
|
||||
.cmf4:
|
||||
.cmf8:
|
||||
call eunimpl
|
||||
ret
|
||||
@@ -818,61 +818,15 @@ gen Call {label,".sri4"}
|
||||
/* Group 5: Floating point arithmetic */
|
||||
/********************************************/
|
||||
|
||||
pat adf $1==4
|
||||
with STACK
|
||||
gen Call {label,".adf4"}
|
||||
/* Floating points are not supported */
|
||||
|
||||
pat adf $1==8
|
||||
with STACK
|
||||
gen Call {label,".adf8"}
|
||||
|
||||
pat sbf $1==4
|
||||
with STACK
|
||||
gen Call {label,".sbf4"}
|
||||
|
||||
pat sbf $1==8
|
||||
with STACK
|
||||
gen Call {label,".sbf8"}
|
||||
|
||||
pat mlf $1==4
|
||||
with STACK
|
||||
gen Call {label,".mlf4"}
|
||||
|
||||
pat mlf $1==8
|
||||
with STACK
|
||||
gen Call {label,".mlf8"}
|
||||
|
||||
pat dvf $1==4
|
||||
with STACK
|
||||
gen Call {label,".dvf4"}
|
||||
|
||||
pat dvf $1==8
|
||||
with STACK
|
||||
gen Call {label,".dvf8"}
|
||||
|
||||
pat ngf $1==4
|
||||
with STACK
|
||||
gen Call {label,".ngf4"}
|
||||
|
||||
pat ngf $1==8
|
||||
with STACK
|
||||
gen Call {label,".ngf8"}
|
||||
|
||||
pat fif $1==4
|
||||
with STACK
|
||||
gen Call {label,".fif4"}
|
||||
|
||||
pat fif $1==8
|
||||
with STACK
|
||||
gen Call {label,".fif8"}
|
||||
|
||||
pat fef $1==4
|
||||
with STACK
|
||||
gen Call {label,".fef4"}
|
||||
|
||||
pat fef $1==8
|
||||
with STACK
|
||||
gen Call {label,".fef8"}
|
||||
pat adf gen Call {label,"eunimpl"}
|
||||
pat sbf gen Call {label,"eunimpl"}
|
||||
pat mlf gen Call {label,"eunimpl"}
|
||||
pat dvf gen Call {label,"eunimpl"}
|
||||
pat ngf gen Call {label,"eunimpl"}
|
||||
pat fif gen Call {label,"eunimpl"}
|
||||
pat fef gen Call {label,"eunimpl"}
|
||||
|
||||
/********************************************/
|
||||
/* Group 6: Pointer arithmetic */
|
||||
@@ -965,13 +919,7 @@ pat zre
|
||||
uses hlreg={const2,0}
|
||||
gen shld {label,$1}
|
||||
|
||||
pat zrf $1==4
|
||||
with STACK
|
||||
gen Call {label,".zrf4"}
|
||||
|
||||
pat zrf $1==8
|
||||
with STACK
|
||||
gen Call {label,".zrf8"}
|
||||
pat zrf gen Call {label,"eunimpl"}
|
||||
|
||||
pat zer $1==2 yields {const2,0}
|
||||
|
||||
@@ -1087,26 +1035,12 @@ with STACK
|
||||
uses areg={const1,0}
|
||||
gen Call {label,".cii"}
|
||||
|
||||
pat cfi
|
||||
with STACK
|
||||
gen Call {label,".cfi"}
|
||||
|
||||
pat cif
|
||||
with STACK
|
||||
gen Call {label,".cif"}
|
||||
|
||||
pat cuf
|
||||
with STACK
|
||||
gen Call {label,".cuf"}
|
||||
|
||||
pat cff
|
||||
with STACK
|
||||
gen Call {label,".cff"}
|
||||
|
||||
pat cfu
|
||||
with STACK
|
||||
gen Call {label,".cfu"}
|
||||
|
||||
pat cfi gen Call {label,"eunimpl"}
|
||||
pat cif gen Call {label,"eunimpl"}
|
||||
pat cuf gen Call {label,"eunimpl"}
|
||||
pat cff gen Call {label,"eunimpl"}
|
||||
pat cfu gen Call {label,"eunimpl"}
|
||||
|
||||
/*****************************************/
|
||||
/* Group 9: Logical instructions */
|
||||
/*****************************************/
|
||||
@@ -1392,13 +1326,7 @@ with STACK
|
||||
uses areg={const1,1}
|
||||
gen Call {label,".cmi4"} yields de
|
||||
|
||||
pat cmf $1==4
|
||||
with STACK
|
||||
gen Call {label,".cmf4"}
|
||||
|
||||
pat cmf $1==8
|
||||
with STACK
|
||||
gen Call {label,".cmf8"}
|
||||
pat cmf gen Call {label,"eunimpl"}
|
||||
|
||||
pat cmu $1==2
|
||||
with hl_or_de hl_or_de
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -23,19 +23,6 @@ static char rcsid[] = "$Header$";
|
||||
* machine dependent back end routines for the Motorola 68000
|
||||
*/
|
||||
|
||||
#define IEEEFLOAT
|
||||
|
||||
#ifdef IEEEFLOAT
|
||||
#include "FP.h"
|
||||
#include "trp.c"
|
||||
#include "fcompact.c"
|
||||
#include "dbl_extract.c"
|
||||
#ifdef PRT_EXP_DEBUG
|
||||
#include "prt_extend.c"
|
||||
#endif
|
||||
#endif IEEEFLOAT
|
||||
|
||||
|
||||
con_part(sz,w) register sz; word w; {
|
||||
|
||||
while (part_size % sz)
|
||||
@@ -61,58 +48,24 @@ con_mult(sz) word sz; {
|
||||
fprintf(codefile,".long %s\n",str);
|
||||
}
|
||||
|
||||
#ifdef IEEEFLOAT
|
||||
dbl_adjust(fl)
|
||||
my_dbl *fl;
|
||||
{
|
||||
EXTEND buf;
|
||||
con_float() {
|
||||
|
||||
/* special routine to strip SGL_BIAS */
|
||||
dbl_extract(fl,&buf);
|
||||
/* standard routine to add DBL_BIAS */
|
||||
fcompact(&buf,fl,sizeof(double));
|
||||
}
|
||||
#endif IEEEFLOAT
|
||||
|
||||
con_float()
|
||||
{
|
||||
register word sz;
|
||||
register long *l;
|
||||
#ifdef IEEEFLOAT
|
||||
register my_dbl *md;
|
||||
#endif IEEEFLOAT
|
||||
double d;
|
||||
char mesg[128];
|
||||
|
||||
sz = argval;
|
||||
if (sz!= 4 && sz!= 8) {
|
||||
sprintf(mesg,"con_float(): bad fcon size %d %D\nstr: %s\n\0",
|
||||
sz,sz,str);
|
||||
fatal(mesg);
|
||||
}
|
||||
|
||||
d = atof(str);
|
||||
l = (long *) &d;
|
||||
|
||||
#ifdef IEEEFLOAT
|
||||
if (sz == 8) {
|
||||
/* ATOF() RETURNS THE PROPER FORMAT FOR A FLOAT */
|
||||
/* BUT NOT FOR A DOUBLE. CORRECT THE FORMAT. */
|
||||
md = (my_dbl *) &d;
|
||||
dbl_adjust(md);
|
||||
}
|
||||
#endif IEEEFLOAT
|
||||
|
||||
while ( sz ) {
|
||||
fprintf(codefile,"\t.word 0x%x,0x%x !float test %s\n",
|
||||
(int)(*l)&0xFFFF,(int)(*l>>16)&0xFFFF,str);
|
||||
sz -=4 ;
|
||||
l++;
|
||||
static int been_here;
|
||||
if (argval != 4 && argval != 8)
|
||||
fatal("bad fcon size");
|
||||
fprintf(codefile,".long\t");
|
||||
if (argval == 8)
|
||||
fprintf(codefile,"F_DUM,");
|
||||
fprintf(codefile,"F_DUM\n");
|
||||
if ( !been_here++)
|
||||
{
|
||||
fprintf(stderr,"Warning : dummy float-constant(s)\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef REGVARS
|
||||
|
||||
|
||||
regscore(off,size,typ,score,totyp)
|
||||
long off;
|
||||
{
|
||||
@@ -140,6 +93,8 @@ regscore(off,size,typ,score,totyp)
|
||||
score -= 1; /* take save/restore into account */
|
||||
return score;
|
||||
}
|
||||
|
||||
|
||||
struct regsav_t {
|
||||
char *rs_reg; /* e.g. "a3" or "d5" */
|
||||
long rs_off; /* offset of variable */
|
||||
@@ -148,10 +103,20 @@ struct regsav_t {
|
||||
|
||||
|
||||
int regnr;
|
||||
int nr_a_regs,nr_d_regs;
|
||||
int TEM_BSIZE;
|
||||
static long nlocals;
|
||||
|
||||
prolog(n)
|
||||
{ nlocals = n; }
|
||||
|
||||
|
||||
i_regsave()
|
||||
{
|
||||
regnr = 0;
|
||||
nr_a_regs = 0;
|
||||
nr_d_regs = 0;
|
||||
TEM_BSIZE = 0;
|
||||
}
|
||||
|
||||
#define MOVEM_LIMIT 2
|
||||
@@ -160,9 +125,11 @@ i_regsave()
|
||||
* we simply use several move.l's.
|
||||
*/
|
||||
|
||||
|
||||
save()
|
||||
{
|
||||
register struct regsav_t *p;
|
||||
int i;
|
||||
|
||||
if (regnr > MOVEM_LIMIT) {
|
||||
fprintf(codefile,"movem.l ");
|
||||
@@ -173,16 +140,37 @@ save()
|
||||
}
|
||||
fprintf(codefile,",-(sp)\n");
|
||||
} else {
|
||||
for (p = regsav; p < ®sav[regnr]; p++) {
|
||||
fprintf(codefile,"move.l %s,-(sp)\n",p->rs_reg);
|
||||
/* Note that the order in which the registers are saved
|
||||
* is important; it is used by gto.s.
|
||||
*/
|
||||
for (i = 0; i < nr_a_regs; i++) {
|
||||
fprintf(codefile,"move.l a%d,-(sp)\n",5-i);
|
||||
}
|
||||
for (i = 0; i < nr_d_regs; i++) {
|
||||
fprintf(codefile,"move.l d%d,-(sp)\n",7-i);
|
||||
}
|
||||
}
|
||||
/* Push a mask that indicates which registers were saved */
|
||||
assert(nr_d_regs < 8 && nr_a_regs < 8);
|
||||
if (nr_d_regs == 0 && nr_a_regs == 0) {
|
||||
fprintf(codefile,"clr.w -(sp)\n");
|
||||
} else {
|
||||
fprintf(codefile,"move.w #%d,-(sp)\n",
|
||||
nr_d_regs + (nr_a_regs<<3));
|
||||
}
|
||||
|
||||
/* Compute AB - LB */
|
||||
TEM_BSIZE = 4 * (nr_d_regs + nr_a_regs) + 10;
|
||||
|
||||
/* allocate space for local variables */
|
||||
fprintf(codefile,"tst.b -%D(sp)\nlink\ta6,#-%D\n",nlocals+40,nlocals);
|
||||
|
||||
/* initialise register-parameters */
|
||||
for (p = regsav; p < ®sav[regnr]; p++) {
|
||||
if (p->rs_off >= 0) {
|
||||
fprintf(codefile,"move.%c %ld(a6),%s\n",
|
||||
(p->rs_size == 4 ? 'l' : 'w'),
|
||||
p->rs_off,
|
||||
p->rs_off + TEM_BSIZE,
|
||||
p->rs_reg);
|
||||
}
|
||||
}
|
||||
@@ -191,7 +179,10 @@ save()
|
||||
restr()
|
||||
{
|
||||
register struct regsav_t *p;
|
||||
int i;
|
||||
|
||||
fprintf(codefile,"unlk a6\n");
|
||||
fprintf(codefile,"add.l #2,sp\n"); /* pop mask */
|
||||
if (regnr > MOVEM_LIMIT) {
|
||||
fprintf(codefile,"movem.l (sp)+,");
|
||||
for (p = regsav; ;) {
|
||||
@@ -201,11 +192,13 @@ restr()
|
||||
}
|
||||
putc('\n',codefile);
|
||||
} else {
|
||||
for (p = ®sav[regnr-1]; p >= regsav; p--) {
|
||||
fprintf(codefile,"move.l (sp)+,%s\n",p->rs_reg);
|
||||
for (i = nr_d_regs - 1; i >= 0; i--) {
|
||||
fprintf(codefile,"move.l (sp)+,d%d\n",7-i);
|
||||
}
|
||||
for (i = nr_a_regs - 1; i >= 0; i--) {
|
||||
fprintf(codefile,"move.l (sp)+,a%d\n",5-i);
|
||||
}
|
||||
}
|
||||
fprintf(codefile,"unlk a6\n");
|
||||
fprintf(codefile,"rts\n");
|
||||
}
|
||||
|
||||
@@ -221,6 +214,12 @@ regsave(str,off,size)
|
||||
{
|
||||
assert (regnr < 9);
|
||||
regsav[regnr].rs_reg = str;
|
||||
if (str[0] == 'a') {
|
||||
nr_a_regs++;
|
||||
} else {
|
||||
assert(str[0] == 'd');
|
||||
nr_d_regs++;
|
||||
}
|
||||
regsav[regnr].rs_off = off;
|
||||
regsav[regnr++].rs_size = size;
|
||||
fprintf(codefile, "!Local %ld into %s\n",off,str);
|
||||
@@ -233,11 +232,15 @@ regreturn()
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef REGVARS
|
||||
|
||||
prolog(nlocals) full nlocals; {
|
||||
|
||||
fprintf(codefile,"tst.b -%D(sp)\nlink\ta6,#-%D\n",nlocals+40,nlocals);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
mes(type) word type ; {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
"$Header$"
|
||||
/*
|
||||
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
*
|
||||
@@ -33,7 +32,6 @@
|
||||
|
||||
EM_WSIZE = 2
|
||||
EM_PSIZE = 4
|
||||
EM_BSIZE = 8
|
||||
|
||||
|
||||
|
||||
@@ -114,8 +112,6 @@ ABS = {STRING addr;} 2 cost=(3,5) "%[addr]"
|
||||
ABS1 = {STRING addr;} 2 cost=(3,5) "%[addr]"
|
||||
IMMEDIATE = {INT cc;} 2 cost=(1,2) "#%[cc]"
|
||||
LOCAL_ADDR = {INT off;} 4 /* not really addressable */
|
||||
REGOFF_ADDR = {REGISTER reg;
|
||||
INT off;} 4 /* not really addressable */
|
||||
EXTERNAL_ADDR = {STRING off;} 4 cost=(4,4) "#%[off]"
|
||||
INDEX_ADDR = {REGISTER reg,ireg;
|
||||
INT di;} 4
|
||||
@@ -156,15 +152,13 @@ ALT_MEM = ALTERABLE * MEMORY
|
||||
DATASCR = DATAREG * SCRATCH
|
||||
ADDSCR = ADDREG * SCRATCH
|
||||
MEM_ALL = ALL - DATAREG - DATAREG4 - ADDREG - IMMEDIATE - IMMEDIATE4
|
||||
- LOCAL_ADDR -REGOFF_ADDR - EXTERNAL_ADDR - DOUBLE - DOUBLEZERO
|
||||
- LOCAL_ADDR - EXTERNAL_ADDR - DOUBLE - DOUBLEZERO
|
||||
ALL_ACCESSIBLE = IADDREG + IADDREG4 + IADDREG1 + INDEXED + INDEXED4
|
||||
|
||||
ANY1 = DISPL1 + ABS1 + IADDREG1
|
||||
DATA_ALT1 = ANY1
|
||||
DATA_ALT_1OR2 = DATA_ALT + DATA_ALT1
|
||||
DATA_ALT_1OR2 = DATA_ALT + ANY1
|
||||
|
||||
|
||||
REG4 = DATAREG4 + ADDREG
|
||||
DATA4 = DATAREG4 + IADDREG4 + DISPL4 + INDEXED4 +
|
||||
ABS4 + IMMEDIATE4 + DOUBLE
|
||||
MEMORY4 = DATA4 - DATAREG4
|
||||
@@ -210,18 +204,13 @@ lil | | allocate(ADDREG = {DISPL4,LB,$1})| {IADDREG,%[a]} | |
|
||||
lof | ADDREG | | {DISPL,%[1],$1} | |
|
||||
... | nocoercions: EXTERNAL_ADDR | | {ABS,%[1.off]+"+"+tostring($1)} | |
|
||||
... | nocoercions: LOCAL_ADDR | | {DISPL,LB,%[1.off]+$1} | |
|
||||
... | nocoercions: REGOFF_ADDR | | {DISPL,%[1.reg],%[1.off]+$1} | |
|
||||
ldf | ADDREG | | {DISPL4,%[1],$1} | |
|
||||
... | nocoercions: EXTERNAL_ADDR | | {ABS4,%[1.off]+"+"+tostring($1)} | |
|
||||
... | nocoercions: LOCAL_ADDR | | {DISPL4,LB,%[1.off]+$1} | |
|
||||
... | nocoercions: REGOFF_ADDR | | {DISPL4,%[1.reg],%[1.off]+$1} | |
|
||||
lal | | | {LOCAL_ADDR,$1} | |
|
||||
| LOCAL_ADDR | allocate(ADDREG)
|
||||
"lea %[1.off](a6),%[a]"
|
||||
samecc | %[a] | |
|
||||
| REGOFF_ADDR | allocate(ADDREG)
|
||||
"lea %[1.off](%[1.reg]),%[a]"
|
||||
samecc | %[a] | |
|
||||
lae | | | {EXTERNAL_ADDR,$1} | |
|
||||
| EXTERNAL_ADDR | allocate(ADDREG)
|
||||
"lea %[1.off],%[a]"
|
||||
@@ -230,33 +219,17 @@ lae | | | {EXTERNAL_ADDR,$1} | |
|
||||
/* For the lxl and lxa instructions we assume that the static link
|
||||
* (i.e. a pointer to the LB of the lexically enclosing subprogram)
|
||||
* is passed as zero-th actual parameter. The distance (in bytes)
|
||||
* between LB and the zero-th parameter is the constant EM_BSIZE
|
||||
* between LB and the zero-th parameter is the constant 8
|
||||
*/
|
||||
|
||||
lxl $1 == 0 | | | LB | |
|
||||
lxl $1 == 1 | | | {DISPL4,LB,8} | |
|
||||
lxl $1>1 | |
|
||||
allocate(ADDREG,DATAREG = {IMMEDIATE,$1-1})
|
||||
"move.l a6,%[a]"
|
||||
"1:"
|
||||
"move.l 8(%[a]),%[a]"
|
||||
"dbf %[b],1b"
|
||||
erase(%[b]) | %[a] | |
|
||||
lxa $1 == 0 | |
|
||||
allocate(ADDREG = {IMMEDIATE4,8})
|
||||
"add.l a6,%[a]"
|
||||
erase(%[a]) | %[a] | |
|
||||
lxa $1 > 0 | |
|
||||
allocate(ADDREG, DATAREG = {IMMEDIATE,$1-1})
|
||||
"move.l a6,%[a]"
|
||||
"1:"
|
||||
"move.l 8(%[a]),%[a]"
|
||||
"dbf %[b],1b"
|
||||
"add.l #8,%[a]"
|
||||
erase(%[b]) | %[a] | |
|
||||
lxl $1>=1 | STACK |
|
||||
"move.w #$1,-(sp)"
|
||||
"jsr .lxl" | A0 | |
|
||||
lxa | STACK | "move.w #$1,-(sp)"
|
||||
"jsr .lxa" | A0 | |
|
||||
loi $1 == 1 | ADDREG | | {IADDREG1, %[1]} | |
|
||||
... | nocoercions: LOCAL_ADDR | | {DISPL1,LB,%[1.off]} | |
|
||||
... | nocoercions: REGOFF_ADDR | | {DISPL1,%[1.reg],%[1.off]} | |
|
||||
... | nocoercions: EXTERNAL_ADDR | | {ABS1,%[1.off]} | |
|
||||
loi $1 == 2 | ADDREG | | {IADDREG,%[1]} | |
|
||||
loi $1 == 4 | ADDREG | | {IADDREG4,%[1]} | |
|
||||
@@ -272,9 +245,7 @@ lae loi $2 == 6 | | remove(ALL)
|
||||
lae loi $2 == 8 | | remove(ALL)
|
||||
"move.l $1+4,-(sp)"
|
||||
"move.l $1,-(sp)" | | |
|
||||
loi $1 == 6 | ADDREG | | {DISPL,%[1],4} {IADDREG4,%[1]} | |
|
||||
loi $1 == 8 | ADDREG | | {DISPL4,%[1],4} {IADDREG4,%[1]} | |
|
||||
loi $1 > 8 | ADDSCR | remove(ALL)
|
||||
loi $1 > 4 | ADDSCR | remove(ALL)
|
||||
allocate(DATAREG4= {IMMEDIATE4,$1/2-1})
|
||||
"add.l #$1,%[1]"
|
||||
"1:"
|
||||
@@ -328,12 +299,10 @@ lpi | | | {EXTERNAL_ADDR,$1} | |
|
||||
|
||||
|
||||
#ifdef REGVARS
|
||||
stl inreg($1)==2 | nocoercions: ANY | remove(regvar($1))
|
||||
stl inreg($1)==2 | ANY | remove(regvar($1))
|
||||
move(%[1],regvar($1)) | | |
|
||||
... | STACK |
|
||||
"move.w (sp)+,%(regvar($1)%)" | | |
|
||||
#endif
|
||||
stl | nocoercions: ANY | remove(DISPL,%[reg] == LB && %[dis] == $1)
|
||||
stl | ANY | remove(DISPL,%[reg] == LB && %[dis] == $1)
|
||||
remove(DISPL4,%[reg] == LB && (%[dis] == $1-2 ||
|
||||
%[dis] == $1))
|
||||
remove(DISPL1,%[reg] == LB && (%[dis] == $1 ||
|
||||
@@ -343,8 +312,6 @@ stl | nocoercions: ANY | remove(DISPL,%[reg] == LB && %[dis] == $1)
|
||||
remove(DISPL1,%[reg] != LB)
|
||||
remove(ALL_ACCESSIBLE)
|
||||
move(%[1],{DISPL,LB,$1}) | | |
|
||||
... | STACK |
|
||||
"move.w (sp)+,$1(a6)" | | |
|
||||
ste | ANY |
|
||||
remove(ABS)
|
||||
remove(ABS4)
|
||||
@@ -411,29 +378,6 @@ sti $1 == 1
|
||||
... | nocoercions: LOCAL_ADDR ANY1 |
|
||||
remove(MEM_ALL)
|
||||
move(%[2],{DISPL1,LB,%[1.off]}) | | |
|
||||
... | nocoercions: REGOFF_ADDR DATAREG |
|
||||
remove(MEM_ALL)
|
||||
move(%[2], {DISPL1,%[1.reg],%[1.off]}) | | |
|
||||
... | nocoercions: REGOFF_ADDR IADDREG |
|
||||
remove(MEM_ALL)
|
||||
move({DISPL,%[2.reg],1}, {DISPL1,%[1.reg],%[1.off]}) | | |
|
||||
... | nocoercions: REGOFF_ADDR DISPL |
|
||||
remove(MEM_ALL)
|
||||
move({DISPL,%[2.reg],%[2.dis]+1}, {DISPL1,%[1.reg],%[1.off]}) | | |
|
||||
... | nocoercions: REGOFF_ADDR INDEXED |
|
||||
remove(MEM_ALL)
|
||||
move({INDEXED,%[2.reg],%[2.ireg],%[2.di]+1},
|
||||
{DISPL1,%[1.reg],%[1.off]}) | | |
|
||||
... | nocoercions: REGOFF_ADDR ABS |
|
||||
remove(MEM_ALL)
|
||||
move({ABS,%[2.addr]+"+1"}, {DISPL1,%[1.reg],%[1.off]}) | | |
|
||||
... | nocoercions: REGOFF_ADDR IMMEDIATE |
|
||||
remove(MEM_ALL)
|
||||
move({IMMEDIATE,(%[2.cc]-((%[2.cc]>>8)<<8)+128)%256-128},
|
||||
{DISPL1,%[1.reg],%[1.off]}) | | |
|
||||
... | nocoercions: REGOFF_ADDR ANY1 |
|
||||
remove(MEM_ALL)
|
||||
move(%[2],{DISPL1,%[1.reg],%[1.off]}) | | |
|
||||
... | nocoercions: EXTERNAL_ADDR DATAREG |
|
||||
remove(MEM_ALL)
|
||||
move(%[2], {ABS1,%[1.off]}) | | |
|
||||
@@ -471,13 +415,10 @@ sts $1 == 2 | | remove(ALL)
|
||||
"jsr .sts"
|
||||
| | |
|
||||
#ifdef REGVARS
|
||||
sdl inreg($1)==2 | nocoercions: ANY4 | remove(regvar($1))
|
||||
sdl inreg($1)==2 | ANY4 | remove(regvar($1))
|
||||
move (%[1],regvar($1)) | | |
|
||||
... | STACK |
|
||||
"move.l (sp)+,%(regvar($1)%)" | | |
|
||||
#endif
|
||||
sdl | nocoercions: ANY4 |
|
||||
remove(DISPL,%[reg] == LB && (%[dis] == $1 || %[dis] == $1+2))
|
||||
sdl | ANY4 | remove(DISPL,%[reg] == LB && (%[dis] == $1 || %[dis] == $1+2))
|
||||
remove(DISPL4,%[reg] == LB && (%[dis] >= $1-2 &&
|
||||
%[dis] <= $1+2))
|
||||
remove(DISPL1,%[reg] == LB && (%[dis] >= $1 &&
|
||||
@@ -487,8 +428,6 @@ sdl | nocoercions: ANY4 |
|
||||
remove(DISPL1,%[reg] != LB)
|
||||
remove(ALL_ACCESSIBLE)
|
||||
move(%[1],{DISPL4,LB,$1}) | | |
|
||||
... | STACK |
|
||||
"move.l (sp)+,$1(a6)" | | |
|
||||
sde | ANY4 |
|
||||
remove(ABS)
|
||||
remove(ABS4)
|
||||
@@ -510,41 +449,6 @@ sdf | ADDREG ANY4 | remove(MEM_ALL)
|
||||
* local variables that are not register-variables.
|
||||
*/
|
||||
|
||||
ldl ldl adp sdl loi $1==$2 && $2==$4 && inreg($1)==2 && $3==1 && $5==1 | |
|
||||
allocate(DATAREG={IMMEDIATE,0})
|
||||
remove(regvar($1))
|
||||
"move.b (%(regvar($1)%))+,%[a]" | %[a] | |
|
||||
ldl ldl adp sdl loi $1==$2 && $2==$4 && inreg($1)==2 && $3==2 && $5==2 | |
|
||||
allocate(DATAREG)
|
||||
remove(regvar($1))
|
||||
"move.w (%(regvar($1)%))+,%[a]" | %[a] | |
|
||||
ldl ldl adp sdl sti $1==$2 && $2==$4 && inreg($1)==2 && $3==1 && $5==1 | DATAREG |
|
||||
remove(regvar($1))
|
||||
"move.b %[1],(%(regvar($1)%))+" | | |
|
||||
ldl ldl adp sdl sti $1==$2 && $2==$4 && inreg($1)==2 && $3==2 && $5==2 | ANY |
|
||||
remove(regvar($1))
|
||||
"move.w %[1],(%(regvar($1)%))+" | | |
|
||||
ldl ldl adp sdl $1==$2 && $2==$4 && inreg($1)==2 | |
|
||||
allocate(ADDREG=regvar($1)) | %[a]
|
||||
| ldl $2 adp $3 sdl $2 |
|
||||
lol inl $1==$2 && inreg($1)==2 | |
|
||||
allocate(DATAREG=regvar($1)) | %[a]
|
||||
| inl $2 |
|
||||
lol inl $1==$2 | |
|
||||
allocate(DATAREG={DISPL,LB,$1}) | %[a]
|
||||
| inl $2 |
|
||||
lol del $1==$2 && inreg($1)==2 | |
|
||||
allocate(DATAREG=regvar($1)) | %[a]
|
||||
| del $2 |
|
||||
lol del $1==$2 | |
|
||||
allocate(DATAREG={DISPL,LB,$1}) | %[a]
|
||||
| del $2 |
|
||||
loe ine $1==$2 | |
|
||||
allocate(DATAREG={ABS,$1}) | %[a]
|
||||
| ine $2 |
|
||||
loe dee $1==$2 | |
|
||||
allocate(DATAREG={ABS,$1}) | %[a]
|
||||
| dee $2 |
|
||||
|
||||
lol adi stl $1 == $3 && $2 == 2 && inreg($1)==2 | ANY |
|
||||
remove(regvar($1))
|
||||
@@ -643,15 +547,14 @@ lol loc slu stl $1 == $4 && $2 == 1 && $3 == 2 && inreg($1)==2 | |
|
||||
remove(regvar($1))
|
||||
"asl.w #1,%(regvar($1)%)"
|
||||
erase(regvar($1)) | | |
|
||||
ldl ldl adp sdl $1 == $2 && $2 == $4 && inreg($1)==2 | |
|
||||
remove(regvar($1))
|
||||
allocate(ADDREG=regvar($1))
|
||||
"add.l #$3,%(regvar($1)%)"
|
||||
erase(regvar($1)) | %[a] | |
|
||||
ldl adp sdl $1 == $3 && inreg($1)==2 | | remove(regvar($1))
|
||||
"add.l #$2,%(regvar($1)%)"
|
||||
erase(regvar($1)) | | |
|
||||
ldl adp dup sdl loi inreg($1) == 2 && $1 == $4 && $3 == 4 && $5 == 4 | | | |
|
||||
ldl $1 adp $2 sdl $1 ldl $1 loi 4 |
|
||||
ldl loi ldl loi adp ldl sti $2==4&&$4==4&&$7==4&&$1==$3&&$1==$6&&inreg($1)==2
|
||||
| | remove(MEM_ALL)
|
||||
allocate(ADDREG = {IADDREG4,regvar($1)})
|
||||
"add.l #$5,(%(regvar($1)%))" | %[a] | |
|
||||
loc ldl ads sdl $2 == $4 && $3 == 2 && inreg($2)==2 | |
|
||||
remove(regvar($2))
|
||||
"add.l #$1,%(regvar($2)%)"
|
||||
@@ -666,12 +569,10 @@ ldc ldl ads sdl $2 == $4 && $3 == 4 && inreg($2)==2 | |
|
||||
erase(regvar($2)) | | |
|
||||
lil inc sil $1==$3 && inreg($1)==2 | |
|
||||
remove(MEM_ALL)
|
||||
"add.w #1,(%(regvar($1)%))"
|
||||
setcc({IADDREG,regvar($1)}) | | |
|
||||
"add.w #1,(%(regvar($1)%))" | | |
|
||||
lil dec sil $1==$3 && inreg($1)==2 | |
|
||||
remove(MEM_ALL)
|
||||
"sub.w #1,(%(regvar($1)%))"
|
||||
setcc({IADDREG,regvar($1)}) | | |
|
||||
"sub.w #1,(%(regvar($1)%))" | | |
|
||||
lol and stl $1 == $3 && $2 == 2 && inreg($1)==2 | ANY |
|
||||
remove(regvar($1))
|
||||
"and.w %[1],%(regvar($1)%)"
|
||||
@@ -866,24 +767,12 @@ lol ngi stl $1 == $3 && $2 == 4 | |
|
||||
loe ngi ste $1 == $3 && $2 == 4 | |
|
||||
remove(MEM_ALL)
|
||||
"neg.l $1" | | |
|
||||
loc sli $1 == 1 && $2 == 2 | DATASCR |
|
||||
"add.w %[1],%[1]"
|
||||
erase(%[1])
|
||||
setcc(%[1]) | %[1] | |
|
||||
loc sli $1 > 1 && $1 <= 8 && $2 == 2 | DATASCR |
|
||||
loc sli $1 >= 1 && $1 <= 8 && $2 == 2 | DATASCR |
|
||||
"asl.w #$1,%[1]"
|
||||
erase(%[1]) | %[1] | |
|
||||
loc sli $1 == 1 && $2 == 4 | DATASCR4 |
|
||||
"add.l %[1],%[1]"
|
||||
erase(%[1])
|
||||
setcc(%[1]) | %[1] | |
|
||||
loc sli $1 > 1 && $1 <= 8 && $2 == 4 | DATASCR4 |
|
||||
loc sli $1 >= 1 && $1 <= 8 && $2 == 4 | DATASCR4 |
|
||||
"asl.l #$1,%[1]"
|
||||
erase(%[1]) | %[1] | |
|
||||
lol loc sli ads inreg($1) == 2 && $2 == 1 && $3 == 2 && $4 == 2 | ADDSCR |
|
||||
"add.w %(regvar($1)%),%[1]"
|
||||
"add.w %(regvar($1)%),%[1]"
|
||||
erase(%[1]) | %[1] | |
|
||||
lol loc sli stl $1 == $4 && $2 == 1 && $3 == 2 | |
|
||||
remove(MEM_ALL)
|
||||
"asl.w #1, $1(a6)" | | |
|
||||
@@ -1035,78 +924,16 @@ adu | | | | adi $1 |
|
||||
sbu | | | | sbi $1 |
|
||||
slu | | | | sli $1 |
|
||||
|
||||
/* Floating point stuff */
|
||||
adf $1==4 | |
|
||||
remove(ALL)
|
||||
"jsr .adf4" | | asp 8 lfr 4 |
|
||||
adf $1==8 | |
|
||||
remove(ALL)
|
||||
"jsr .adf8" | | asp 16 lfr 4 loi 8 |
|
||||
sbf $1==4 | |
|
||||
remove(ALL)
|
||||
"jsr .sbf4" | | asp 8 lfr 4 |
|
||||
sbf $1==8 | |
|
||||
remove(ALL)
|
||||
"jsr .sbf8" | | asp 16 lfr 4 loi 8 |
|
||||
mlf $1==4 | |
|
||||
remove(ALL)
|
||||
"jsr .mlf4" | | asp 8 lfr 4 |
|
||||
mlf $1==8 | |
|
||||
remove(ALL)
|
||||
"jsr .mlf8" | | asp 16 lfr 4 loi 8 |
|
||||
dvf $1==4 | |
|
||||
remove(ALL)
|
||||
"jsr .dvf4" | | asp 8 lfr 4 |
|
||||
dvf $1==8 | |
|
||||
remove(ALL)
|
||||
"jsr .dvf8" | | asp 16 lfr 4 loi 8 |
|
||||
ngf $1==4 | |
|
||||
remove(ALL)
|
||||
"jsr .ngf4" | | asp 4 lfr 4 |
|
||||
ngf $1==8 | |
|
||||
remove(ALL)
|
||||
"jsr .ngf8" | | asp 16 lfr 4 loi 8 |
|
||||
fif $1==4 | |
|
||||
remove(ALL)
|
||||
"jsr .fif4" | | asp 16 lfr 4 loi 8 |
|
||||
fif $1==8 | |
|
||||
remove(ALL)
|
||||
"jsr .fif8" | | asp 16 lfr 4 loi 16 |
|
||||
fef $1==4 | |
|
||||
remove(ALL)
|
||||
"jsr .fef4" | | asp 4 lfr 4 loi 8 |
|
||||
fef $1==8 | |
|
||||
remove(ALL)
|
||||
"jsr .fef8" | | asp 8 lfr 4 loi 12 |
|
||||
|
||||
|
||||
|
||||
/* G R O U P VI : P O I N T E R A R I T H M E T I C */
|
||||
|
||||
adp $1 >= 1 && $1 <= 8
|
||||
| nocoercions: EXTERNAL_ADDR | | {EXTERNAL_ADDR,%[1.off] + "+"
|
||||
+ tostring($1)} | |
|
||||
... | nocoercions: LOCAL_ADDR | | {LOCAL_ADDR,%[1.off]+$1} | |
|
||||
... | nocoercions: REGOFF_ADDR | | {REGOFF_ADDR,%[1.reg],%[1.off]+$1} | |
|
||||
... | nocoercions: ADDREG | | {REGOFF_ADDR,%[1],$1} | |
|
||||
... | ADDSCR | "add.l #$1,%[1]"
|
||||
adp $1 >= 1 && $1 <= 8 | ADDSCR | "add.l #$1,%[1]"
|
||||
erase(%[1])
|
||||
setcc(%[1]) | %[1] | |
|
||||
adp $1 >= 0-32767 && $1 <= 32767
|
||||
| nocoercions: EXTERNAL_ADDR | | {EXTERNAL_ADDR,%[1.off] + "+"
|
||||
+ tostring($1)} | |
|
||||
... | nocoercions: LOCAL_ADDR | | {LOCAL_ADDR,%[1.off]+$1} | |
|
||||
... | nocoercions: REGOFF_ADDR | | {REGOFF_ADDR,%[1.reg],%[1.off]+$1} | |
|
||||
... | nocoercions: ADDREG | | {REGOFF_ADDR,%[1],$1} | |
|
||||
... | ADDSCR | "lea $1(%[1]),%[1]"
|
||||
adp | ADDSCR | "lea $1(%[1]),%[1]"
|
||||
erase(%[1])
|
||||
setcc(%[1]) | %[1] | |
|
||||
adp | nocoercions: EXTERNAL_ADDR | | {EXTERNAL_ADDR,%[1.off] + "+"
|
||||
+ tostring($1)} | |
|
||||
... | ADDSCR | "add.l #$1,%[1]"
|
||||
erase(%[1])
|
||||
setcc(%[1]) | %[1] | |
|
||||
|
||||
/* The next patterns are for efficient translation of "*p++" in C */
|
||||
ldl ldl adp sdl $1 == $2 && $2 == $4 | |
|
||||
allocate(ADDREG={DISPL4,LB,$1})
|
||||
@@ -1175,12 +1002,10 @@ inc | DATASCR | "add.w #1,%[1]"
|
||||
#ifdef REGVARS
|
||||
lil inc sil $1==$3 && inreg($1) == 2 | |
|
||||
remove(MEM_ALL)
|
||||
"add.w #1,(%(regvar($1)%))"
|
||||
setcc({IADDREG,regvar($1)}) | | |
|
||||
"add.w #1,(%(regvar($1)%))" | | |
|
||||
lil dec sil $1==$3 && inreg($1) == 2 | |
|
||||
remove(MEM_ALL)
|
||||
"sub.w #1,(%(regvar($1)%))"
|
||||
setcc({IADDREG,regvar($1)}) | | |
|
||||
"sub.w #1,(%(regvar($1)%))" | | |
|
||||
#endif
|
||||
lil inc sil $1==$3 | | allocate(ADDREG={DISPL4,LB,$1})
|
||||
remove(MEM_ALL)
|
||||
@@ -1293,7 +1118,6 @@ zer $1 > 12 | | remove(ALL)
|
||||
"1:"
|
||||
"clr -(sp)"
|
||||
"dbf %[a],1b" | | |
|
||||
zrf | | | | zer $1 |
|
||||
|
||||
|
||||
|
||||
@@ -1343,88 +1167,6 @@ loc loc ciu $1==4 && $2==2 | DATAREG4 | | %[1.1] | |
|
||||
loc loc cui $1==4 && $2==2 | DATAREG4 | | %[1.1] | |
|
||||
... | ANY | | | |
|
||||
|
||||
/* Floating point stuff */
|
||||
|
||||
loc loc cif $1==2 && $2==4 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"jsr .cif4" | | asp 4 lfr 4 |
|
||||
loc loc cif $1==2 && $2==8 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"jsr .cif8" | | asp 4 lfr 4 loi 8 |
|
||||
loc loc cif $1==4 && $2==4 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"jsr .cif4" | | asp 6 lfr 4 |
|
||||
loc loc cif $1==4 && $2==8 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"jsr .cif8" | | asp 6 lfr 4 loi 8 |
|
||||
loc loc cuf $1==2 && $2==4 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"jsr .cuf4" | | asp 4 lfr 4 |
|
||||
loc loc cuf $1==2 && $2==8 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"jsr .cuf8" | | asp 4 lfr 4 loi 8 |
|
||||
loc loc cuf $1==4 && $2==4 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"jsr .cuf4" | | asp 6 lfr 4 |
|
||||
loc loc cuf $1==4 && $2==8 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"jsr .cuf8" | | asp 6 lfr 4 loi 8 |
|
||||
loc loc cfi $1==4 && $2==2 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"move.w #$2,-(sp)"
|
||||
"jsr .cfi" | | asp 8 lfr 2 |
|
||||
loc loc cfi $1==4 && $2==4 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"move.w #$2,-(sp)"
|
||||
"jsr .cfi" | | asp 8 lfr 4 |
|
||||
loc loc cfi $1==8 && $2==2 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"move.w #$2,-(sp)"
|
||||
"jsr .cfi" | | asp 12 lfr 2 |
|
||||
loc loc cfi $1==8 && $2==4 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"move.w #$2,-(sp)"
|
||||
"jsr .cfi" | | asp 12 lfr 4 |
|
||||
loc loc cfu $1==4 && $2==2 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"move.w #$2,-(sp)"
|
||||
"jsr .cfu" | | asp 8 lfr 2 |
|
||||
loc loc cfu $1==4 && $2==4 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"move.w #$2,-(sp)"
|
||||
"jsr .cfu" | | asp 8 lfr 4 |
|
||||
loc loc cfu $1==8 && $2==2 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"move.w #$2,-(sp)"
|
||||
"jsr .cfu" | | asp 12 lfr 2 |
|
||||
loc loc cfu $1==8 && $2==4 | |
|
||||
remove(ALL)
|
||||
"move.w #$1,-(sp)"
|
||||
"move.w #$2,-(sp)"
|
||||
"jsr .cfu" | | asp 12 lfr 4 |
|
||||
loc loc cff $1==8 && $2==4 | |
|
||||
remove(ALL)
|
||||
"jsr .cff4" | | asp 8 lfr 4 |
|
||||
loc loc cff $1==4 && $2==8 | |
|
||||
remove(ALL)
|
||||
"jsr .cff8" | | asp 4 lfr 4 loi 8 |
|
||||
|
||||
|
||||
/* G R O U P IX : L O G I C A L */
|
||||
|
||||
and defined($1) && $1 == 2 | ANY DATASCR |
|
||||
@@ -1435,11 +1177,6 @@ and defined($1) && $1 == 2 | ANY DATASCR |
|
||||
"and %[2],%[1]"
|
||||
setcc(%[1])
|
||||
erase(%[1]) | %[1] | | (2,2)+%[2]
|
||||
lol loc and $2 == 255 && inreg($1) < 2 && $3 == 2 | | | {DISPL1,LB,$1+1} | |
|
||||
lal loi and lal sti $1 == $4 && $2 == 1 && $3 == 2 && $5 == 1 && inreg($1) < 2
|
||||
| DATAREG |
|
||||
remove(MEM_ALL)
|
||||
"and.b %[1],$1(a6)" | | |
|
||||
loc lol and stl $2 == $4 && $3 == 2 && inreg($2) < 2 | |
|
||||
remove(MEM_ALL)
|
||||
"and.w #$1,$2(a6)" | | | (6,10)
|
||||
@@ -1519,10 +1256,6 @@ ior defined($1) && $1 == 2 | ANY DATASCR |
|
||||
"or %[2],%[1]"
|
||||
erase(%[1])
|
||||
setcc(%[1]) | %[1] | | (2,2)+%[2]
|
||||
lal loi ior lal sti $1 == $4 && $2 == 1 && $3 == 2 && $5 == 1 && inreg($1) < 2
|
||||
| DATAREG |
|
||||
remove(MEM_ALL)
|
||||
"or.b %[1],$1(a6)" | | |
|
||||
loc lol ior stl $2 == $4 && $3 == 2 && inreg($2) < 2 | |
|
||||
remove(MEM_ALL)
|
||||
"or.w #$1,$2(a6)" | | | (6,10)
|
||||
@@ -1599,10 +1332,6 @@ xor defined($1) && $1 == 2 | DATAREG DATASCR |
|
||||
"eor %[2],%[1]"
|
||||
erase(%[1])
|
||||
setcc(%[1]) | %[1] | | (2,2)+%[2]
|
||||
lal loi xor lal sti $1 == $4 && $2 == 1 && $3 == 2 && $5 == 1 && inreg($1) < 2
|
||||
| DATAREG |
|
||||
remove(MEM_ALL)
|
||||
"eor.b %[1],$1(a6)" | | |
|
||||
lol loc xor stl $1 == $4 && $3 == 2 | |
|
||||
remove(MEM_ALL)
|
||||
"eor.w #$2,$1(a6)" | | | (6,10)
|
||||
@@ -1854,15 +1583,6 @@ cms !defined($1) | ANY | remove(ALL)
|
||||
cmp | | remove(ALL)
|
||||
"jsr .cmp"
|
||||
| D1 | |
|
||||
/* floating point */
|
||||
|
||||
cmf $1==4 | |
|
||||
remove(ALL)
|
||||
"jsr .cmf4" | | asp 8 lfr 2 |
|
||||
cmf $1==8 | |
|
||||
remove(ALL)
|
||||
"jsr .cmf8" | | asp 16 lfr 2 |
|
||||
|
||||
|
||||
cmi tlt and $1==2 && $3==2 | ANY DATAREG DATASCR |
|
||||
"cmp %[1],%[2]"
|
||||
@@ -2245,22 +1965,22 @@ ldc cmi tgt loww(1)==0&&highw(1)==0 | DATA_ALT4 | allocate(DATAREG={IMMEDIATE,1}
|
||||
"clr %[a]"
|
||||
"1:"
|
||||
erase(%[a]) | %[a] | |
|
||||
cmi zlt $1==4 | ANY4 REG4 STACK |
|
||||
cmi zlt $1==4 | ANY4 DATAREG4 STACK |
|
||||
"cmp.l %[1],%[2]"
|
||||
"blt $2" | | |
|
||||
cmi zle $1==4 | ANY4 REG4 STACK |
|
||||
cmi zle $1==4 | ANY4 DATAREG4 STACK |
|
||||
"cmp.l %[1],%[2]"
|
||||
"ble $2" | | |
|
||||
cmi zeq $1==4 | ANY4 REG4 STACK |
|
||||
cmi zeq $1==4 | ANY4 DATAREG4 STACK |
|
||||
"cmp.l %[1],%[2]"
|
||||
"beq $2" | | |
|
||||
cmi zne $1==4 | ANY4 REG4 STACK |
|
||||
cmi zne $1==4 | ANY4 DATAREG4 STACK |
|
||||
"cmp.l %[1],%[2]"
|
||||
"bne $2" | | |
|
||||
cmi zge $1==4 | ANY4 REG4 STACK |
|
||||
cmi zge $1==4 | ANY4 DATAREG4 STACK |
|
||||
"cmp.l %[1],%[2]"
|
||||
"bge $2" | | |
|
||||
cmi zgt $1==4 | ANY4 REG4 STACK |
|
||||
cmi zgt $1==4 | ANY4 DATAREG4 STACK |
|
||||
"cmp.l %[1],%[2]"
|
||||
"bgt $2" | | |
|
||||
ldc cmi zlt loww(1)==0&&highw(1)==0 && $2==4 | DATA_ALT4 STACK |
|
||||
@@ -2506,21 +2226,6 @@ tgt | DATA_ALT | allocate(DATAREG={IMMEDIATE,1})
|
||||
/* G R O U P XIII : B R A N C H */
|
||||
|
||||
bra | STACK | "bra $1" | | |
|
||||
/* byte comparisons */
|
||||
loc beq $1 >= 0 && $1 < 128 | nocoercions: DATA_ALT1 |
|
||||
remove(ALL)
|
||||
"cmp.b #$1,%[1]"
|
||||
"beq $2" | | |
|
||||
... | DATA_ALT STACK |
|
||||
"cmp #$1,%[1]"
|
||||
"beq $2" | | |
|
||||
loc bne $1 >= 0 && $1 < 128 | nocoercions: DATA_ALT1 |
|
||||
remove(ALL)
|
||||
"cmp.b #$1,%[1]"
|
||||
"bne $2" | | |
|
||||
... | DATA_ALT STACK |
|
||||
"cmp #$1,%[1]"
|
||||
"bne $2" | | |
|
||||
blt | IMMEDIATE DATA_ALT STACK | "cmp %[1],%[2]"
|
||||
"blt $1" | | |
|
||||
... | ANY DATAREG STACK | "cmp %[1],%[2]"
|
||||
@@ -2758,12 +2463,8 @@ dus $1 == 2 | DATASCR | remove(ALL)
|
||||
exg | STACK | "move.w #$1,d0"
|
||||
"jsr .exg" | | |
|
||||
fil | | "move.l #$1,.filn" | | |
|
||||
gto | STACK | allocate(ADDREG)
|
||||
"lea $1,%[a]"
|
||||
"move.l 4(%[a]),sp"
|
||||
"move.l 8(%[a]),a6"
|
||||
"move.l (%[a]),%[a]"
|
||||
"jmp (%[a])" | | |
|
||||
gto | STACK | "pea $1"
|
||||
"jmp .gto" | | |
|
||||
lin | | "move.w #$1,.lino" | | |
|
||||
lni | | "add.w #1,.lino" | | |
|
||||
mon | STACK | "jsr .mon" | | |
|
||||
@@ -2772,7 +2473,7 @@ lim | | | {ABS4,".trpim"} | |
|
||||
lor $1 == 0 | | | LB | |
|
||||
lor $1 == 1 | STACK | "move.l sp,-(sp)" | | |
|
||||
lor $1 == 2 | | | {ABS4,".reghp"} | |
|
||||
lpb | | | | adp 8 |
|
||||
lpb | STACK | "jsr .lpb" | A0 | |
|
||||
rck $1 == 2 | | remove(ALL)
|
||||
"jsr .rck"
|
||||
| | |
|
||||
@@ -2788,6 +2489,27 @@ str $1 == 2 | | remove(ALL)
|
||||
trp | STACK | "jsr .trp" | | |
|
||||
|
||||
|
||||
/* For several floating point instructions we generate an illegal
|
||||
* instruction trap.
|
||||
*/
|
||||
|
||||
adf | | | | loc 18 trp |
|
||||
sbf | | | | loc 18 trp |
|
||||
mlf | | | | loc 18 trp |
|
||||
dvf | | | | loc 18 trp |
|
||||
ngf | | | | loc 18 trp |
|
||||
fef | | | | loc 18 trp |
|
||||
fif | | | | loc 18 trp |
|
||||
zrf | | | | loc 18 trp |
|
||||
cfi | | | | loc 18 trp |
|
||||
cif | | | | loc 18 trp |
|
||||
cuf | | | | loc 18 trp |
|
||||
cff | | | | loc 18 trp |
|
||||
cfu | | | | loc 18 trp |
|
||||
cmf | | | | loc 18 trp |
|
||||
|
||||
|
||||
|
||||
/* C O E R C I O N S */
|
||||
|
||||
|
||||
@@ -2858,7 +2580,6 @@ STACKS:
|
||||
(ANY, , "move.w %[1],-(sp)" setcc(%[1]), (2,4) + %[1])
|
||||
(EXTERNAL_ADDR, , "pea %[1.off]" nocc)
|
||||
(LOCAL_ADDR, , "pea %[1.off](a6)" nocc)
|
||||
(REGOFF_ADDR, , "pea %[1.off](%[1.reg])" nocc)
|
||||
(INDEX_ADDR, , "pea %[1.di](%[1.reg],%[1.ireg].w)" nocc)
|
||||
(IMMEDIATE4 %[cc] == 0, , "clr.l -(sp)")
|
||||
(IMMEDIATE4, , "pea %[1.cc]" nocc)
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
static char rcsid[] = "$Header$";
|
||||
#define MAXBYTE 24
|
||||
#include <stdio.h>
|
||||
char hex[] = "0123456789ABCDEF";
|
||||
FILE *fp, *fopen();
|
||||
char **s;
|
||||
int bytes, bytcnt, checksum;
|
||||
long pc;
|
||||
|
||||
|
||||
main (argc,argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
if (argc != 2) fatal ("usage: %s filename\n",argv[0]);
|
||||
if ((fp = fopen (*++argv,"r")) == NULL)
|
||||
fatal ("can't open %s\n",*argv);
|
||||
else {
|
||||
s = argv;
|
||||
convert ();
|
||||
fclose (fp);
|
||||
}
|
||||
}
|
||||
|
||||
convert ()
|
||||
{
|
||||
int c;
|
||||
do
|
||||
{
|
||||
pc = getword ();
|
||||
pc = (pc << 16) | getword ();
|
||||
bytes = getword ();
|
||||
while (bytes != 0)
|
||||
{
|
||||
bytcnt = (bytes < MAXBYTE) ? bytes : MAXBYTE;
|
||||
bytes -= bytcnt;
|
||||
checksum = 0;
|
||||
if (pc > 0xffffL) S2record (); else S1record ();
|
||||
}
|
||||
c = getc (fp);
|
||||
ungetc (c, fp);
|
||||
}
|
||||
while (c != EOF);
|
||||
printf ("S9030000FC\n");
|
||||
}
|
||||
|
||||
|
||||
S2record ()
|
||||
{
|
||||
printf ("S2");
|
||||
bytcnt += 4;
|
||||
outbyte (bytcnt);
|
||||
outbyte (pc);
|
||||
record ();
|
||||
}
|
||||
|
||||
S1record ()
|
||||
{
|
||||
printf ("S1");
|
||||
bytcnt += 3;
|
||||
outbyte (bytcnt);
|
||||
record ();
|
||||
}
|
||||
|
||||
record ()
|
||||
{
|
||||
outbyte (pc << 8);
|
||||
outbyte (pc << 16);
|
||||
while (bytcnt != 0)
|
||||
{
|
||||
outbyte (getbyte ());
|
||||
pc ++;
|
||||
}
|
||||
outbyte (~checksum);
|
||||
putchar ('\n');
|
||||
putchar (0);
|
||||
putchar (0);
|
||||
}
|
||||
|
||||
outbyte (b)
|
||||
int b;
|
||||
{
|
||||
checksum = (checksum + b) & 0377;
|
||||
putchar (hex[(b>>4) & 017]);
|
||||
putchar (hex[b & 017]);
|
||||
-- bytcnt;
|
||||
}
|
||||
|
||||
getword ()
|
||||
{
|
||||
int c;
|
||||
c = getbyte ();
|
||||
return ((getbyte () << 8) | c );
|
||||
}
|
||||
|
||||
getbyte ()
|
||||
{
|
||||
int c;
|
||||
if ((c = getc (fp)) == EOF) fatal ("end of %s\n",*s);
|
||||
return (c);
|
||||
}
|
||||
fatal (s,a)
|
||||
{
|
||||
printf (s,a);
|
||||
exit (-1);
|
||||
}
|
||||
@@ -2,6 +2,6 @@
|
||||
.extern _times
|
||||
.text
|
||||
_times: move.w #0x2B,d0
|
||||
move.l 4(sp),a0
|
||||
move.w 4(sp),a0
|
||||
trap #0
|
||||
rts
|
||||
|
||||
@@ -2,20 +2,15 @@ tail_mon.a
|
||||
exit.s
|
||||
_exit.s
|
||||
access.s
|
||||
acct.s
|
||||
alarm.s
|
||||
chdir.s
|
||||
chmod.s
|
||||
chown.s
|
||||
chroot.s
|
||||
close.s
|
||||
creat.s
|
||||
dup.s
|
||||
dup2.s
|
||||
execl.s
|
||||
execve.s
|
||||
fork.s
|
||||
ftime.s
|
||||
getegid.s
|
||||
getgid.s
|
||||
getpid.s
|
||||
@@ -25,16 +20,12 @@ gtty.s
|
||||
ioctl.s
|
||||
kill.s
|
||||
link.s
|
||||
lock.s
|
||||
lseek.s
|
||||
mknod.s
|
||||
mount.s
|
||||
nice.s
|
||||
open.s
|
||||
pause.s
|
||||
pipe.s
|
||||
profil.s
|
||||
ptrace.s
|
||||
read.s
|
||||
setgid.s
|
||||
setuid.s
|
||||
@@ -43,10 +34,8 @@ stime.s
|
||||
sync.s
|
||||
time.s
|
||||
times.s
|
||||
umask.s
|
||||
umount.s
|
||||
unlink.s
|
||||
utime.s
|
||||
write.s
|
||||
brk.s
|
||||
wait.s
|
||||
@@ -54,4 +43,3 @@ fstat.s
|
||||
signal.s
|
||||
call.s
|
||||
cleanup.s
|
||||
errno.s
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,135 +0,0 @@
|
||||
#ifndef NORCSID
|
||||
static char rcsid[] = "$Header$";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
*
|
||||
* This product is part of the Amsterdam Compiler Kit.
|
||||
*
|
||||
* Permission to use, sell, duplicate or disclose this software must be
|
||||
* obtained in writing. Requests for such permissions may be sent to
|
||||
*
|
||||
* Dr. Andrew S. Tanenbaum
|
||||
* Wiskundig Seminarium
|
||||
* Vrije Universiteit
|
||||
* Postbox 7161
|
||||
* 1007 MC Amsterdam
|
||||
* The Netherlands
|
||||
*
|
||||
* Author: Hans van Staveren
|
||||
*/
|
||||
|
||||
char buf[512];
|
||||
char *index();
|
||||
|
||||
main() {
|
||||
register n,sa;
|
||||
register char *p;
|
||||
|
||||
sa=0;
|
||||
for (;;) {
|
||||
getline(buf);
|
||||
if (n=stackadjust()) {
|
||||
sa += n;
|
||||
continue;
|
||||
}
|
||||
if (nullinstruction())
|
||||
continue;
|
||||
if (sa) {
|
||||
if (buf[0]=='t' && buf[1]=='s' && buf[2]=='t' && buf[3]==' ') {
|
||||
sa -= 2;
|
||||
buf[0]='m';
|
||||
buf[1]='o';
|
||||
buf[2]='v';
|
||||
strcat(buf,",(sp)+");
|
||||
} else if (buf[0]=='m' && buf[1]=='o' && buf[2]=='v' &&
|
||||
buf[3]==' ' && (p=index(&buf[5],','))!=0 &&
|
||||
p[1]=='-' && p[2]=='(' && p[3]=='s') {
|
||||
sa -= 2;
|
||||
p[1]=' ';
|
||||
}
|
||||
}
|
||||
switch(sa) {
|
||||
case 0:break;
|
||||
case 2:puts("tst (sp)+");sa=0;break;
|
||||
case 4:puts("cmp (sp)+,(sp)+");sa=0;break;
|
||||
case 6:puts("add $06,sp");sa=0;break;
|
||||
}
|
||||
puts(buf);
|
||||
}
|
||||
}
|
||||
|
||||
getline(buf) register char *buf; {
|
||||
register c;
|
||||
|
||||
while ((c=getchar())==' ' || c=='\t')
|
||||
;
|
||||
if (c==EOF)
|
||||
exit(0);
|
||||
do *buf++=c;
|
||||
while ((c=getchar())!='\n');
|
||||
*buf=0;
|
||||
}
|
||||
|
||||
stackadjust() {
|
||||
|
||||
if (buf[0]=='t' &&
|
||||
buf[1]=='s' &&
|
||||
buf[2]=='t' &&
|
||||
buf[3]==' ' &&
|
||||
buf[4]=='(' &&
|
||||
buf[5]=='s' &&
|
||||
buf[6]=='p' &&
|
||||
buf[7]==')' &&
|
||||
buf[8]=='+') return(2);
|
||||
if (buf[0]=='c' &&
|
||||
buf[1]=='m' &&
|
||||
buf[2]=='p' &&
|
||||
buf[3]==' ' &&
|
||||
buf[4]=='(' &&
|
||||
buf[5]=='s' &&
|
||||
buf[6]=='p' &&
|
||||
buf[7]==')' &&
|
||||
buf[8]=='+' &&
|
||||
buf[9]==',' &&
|
||||
buf[10]=='(' &&
|
||||
buf[11]=='s' &&
|
||||
buf[12]=='p' &&
|
||||
buf[13]==')' &&
|
||||
buf[14]=='+') return(4);
|
||||
if (buf[0]=='a' &&
|
||||
buf[1]=='d' &&
|
||||
buf[2]=='d' &&
|
||||
buf[3]==' ' &&
|
||||
buf[4]=='$' &&
|
||||
buf[5]=='0' &&
|
||||
buf[6]=='6' &&
|
||||
buf[7]==',' &&
|
||||
buf[8]=='s' &&
|
||||
buf[9]=='p' &&
|
||||
buf[10]==0) return(6);
|
||||
return(0);
|
||||
}
|
||||
|
||||
nullinstruction() {
|
||||
register char *p;
|
||||
|
||||
if (buf[4]=='$' && buf[5]=='0' && buf[6]=='0' && buf[7]==',') {
|
||||
p=index(buf,'-');
|
||||
if (p!=0 && p[1]=='(')
|
||||
return(0);
|
||||
p=index(buf,'+');
|
||||
if (p!=0 && p[-1]==')')
|
||||
return(0);
|
||||
if (buf[0]=='b' && buf[1]=='i' && (buf[2]=='s' || buf[2]=='c'))
|
||||
return(1);
|
||||
if (buf[0]=='a' && buf[1]=='d' && buf[2]=='d')
|
||||
return(1);
|
||||
if (buf[0]=='s' && buf[1]=='u' && buf[2]=='b')
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
MAKEFILE=../../proto/libg/Makefile
|
||||
MACHDEF="MACH=pdp -Rbe-p2" "SUF=s" "ASAR=ar"
|
||||
PCDEF="PREF=pc" "SUB=" "SRC=lang/pc/libpc"
|
||||
LIBDIR=../lib
|
||||
|
||||
install:
|
||||
make -f $(MAKEFILE) $(PCDEF) $(MACHDEF) cp
|
||||
|
||||
cmp:
|
||||
make -f $(MAKEFILE) $(PCDEF) $(MACHDEF) all
|
||||
cmp head_pc $(LIBDIR)/head_pc
|
||||
cmp tail_pc $(LIBDIR)/tail_pc
|
||||
|
||||
clean:
|
||||
-rm -f *.old *.[ce$(SUF)] tail* head*
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
|
||||
pr:
|
||||
@pr Makefile
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,252 +0,0 @@
|
||||
/* @(#)comm0.h 1.8 */
|
||||
/*
|
||||
* All preprocessor based options/constants/functions
|
||||
*/
|
||||
|
||||
/* ========== ON/OFF options (use #define in mach0.c) ========== */
|
||||
|
||||
/*
|
||||
* The following options are available, to be set/removed in "mach0.c":
|
||||
* THREE_PASS: three passes needed for branch optimization
|
||||
* BYTES_REVERSED: lowest target address for word high-order byte
|
||||
* WORDS_REVERSED: lowest target address for long high-order byte
|
||||
* LISTING: include listing facilities
|
||||
* RELOCATION: relocatable code generated
|
||||
* DEBUG: for debugging purposes only
|
||||
* TMPDIR: directory for temporary files
|
||||
* ASLD: combined assembler/linker
|
||||
* AOUTSEEK: seek on a.out instead of multiple opens
|
||||
*/
|
||||
|
||||
/* ========== constants (use #undef, #define in mach0.c) ========== */
|
||||
|
||||
/* table sizes */
|
||||
#define STRINGMAX 200 /* <= 256 */
|
||||
#define BITMAX 2000 /* for short or long branches */
|
||||
#define SECTMAX 64
|
||||
#define NAMEMAX 80
|
||||
#define MEMINCR 2048
|
||||
|
||||
/* Some character constants for parsing */
|
||||
#define ASC_LPAR '['
|
||||
#define ASC_RPAR ']'
|
||||
#define ASC_SQUO '\''
|
||||
#define ASC_DQUO '"'
|
||||
#define ASC_COMM '!'
|
||||
#define ISALPHA(c) (isalpha(c) || (c) == '_' || (c) == '.')
|
||||
#define ISALNUM(c) (isalnum(c) || (c) == '_')
|
||||
|
||||
#define GENLAB "I" /* compiler generated labels */
|
||||
|
||||
#define ushort unsigned short
|
||||
|
||||
#define valu_t short /* type of expression values */
|
||||
#define addr_t ushort /* type of dot */
|
||||
#define word_t short /* type of keyword value */
|
||||
/*
|
||||
* NOTE: word_t is introduced to reduce the tokenfile size for machines
|
||||
* with large expressions but smaller opcodes (68000)
|
||||
*/
|
||||
|
||||
#define ALIGNWORD 1
|
||||
#define ALIGNSECT 1
|
||||
|
||||
#define machstart(x) /* nothing */
|
||||
#define machfinish(x) /* nothing */
|
||||
|
||||
#define SETBASE(sp) ((long)(sp)->s_base)
|
||||
|
||||
#define VALWIDTH 4
|
||||
|
||||
/* ========== Machine dependent option/constant settings ========== */
|
||||
|
||||
#include "mach0.c"
|
||||
|
||||
/* ========== default option setting ========== */
|
||||
|
||||
#ifndef NOLD
|
||||
#define ASLD /* default ON */
|
||||
#endif
|
||||
|
||||
#ifndef ASLD
|
||||
#ifndef RELOCATION
|
||||
separate linker only possible if relocation info produced
|
||||
#endif RELOCATION
|
||||
#endif ASLD
|
||||
|
||||
#ifndef DEBUG
|
||||
#define DEBUG 1
|
||||
#endif
|
||||
|
||||
/* ========== Machine independent type declarations ========== */
|
||||
|
||||
#ifdef _include
|
||||
_include <stdio.h>
|
||||
_include <ctype.h>
|
||||
_include <signal.h>
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef ASLD
|
||||
#include "aar.h"
|
||||
#endif
|
||||
#include "out.h"
|
||||
|
||||
#if DEBUG == 0
|
||||
#define assert(ex) /* nothing */
|
||||
#endif
|
||||
|
||||
#if DEBUG == 1
|
||||
#define assert(ex) {if (!(ex)) assert1();}
|
||||
#endif
|
||||
|
||||
#if DEBUG == 2
|
||||
#define assert(ex) {if (!(ex)) assert2(__FILE__, __LINE__);}
|
||||
#endif
|
||||
|
||||
#define CTRL(x) ((x) & 037)
|
||||
|
||||
#define lowb(z) ((int)(z) & 0xFF)
|
||||
#define loww(z) ((int)(z) & 0xFFFF)
|
||||
|
||||
#define fitb(x) ((((x) + 0x80) & ~0xFF) == 0)
|
||||
#define fitw(x) ((((x) + 0x8000) & ~0xFFFF) == 0)
|
||||
|
||||
#define fit(x) if (!(x)) nofit()
|
||||
|
||||
#define PASS_1 0
|
||||
#define PASS_2 1
|
||||
#define PASS_3 2
|
||||
|
||||
#ifdef THREE_PASS
|
||||
#define PASS_SYMB (pass != PASS_1)
|
||||
#define PASS_RELO (pass != PASS_1)
|
||||
#else
|
||||
#define PASS_SYMB 1
|
||||
#define PASS_RELO 1
|
||||
#endif THREE_PASS
|
||||
|
||||
#ifdef ASLD
|
||||
#define RELOMOVE(a,b) /* empty */
|
||||
#else
|
||||
#define RELOMOVE(a,b) {a = b; b = 0;}
|
||||
#endif
|
||||
|
||||
/* symbol table management */
|
||||
#define H_SIZE 256 /* hash size */
|
||||
#define H_KEY (0*H_SIZE) /* key symbol headers */
|
||||
#define H_LOCAL (1*H_SIZE) /* module symbol headers */
|
||||
#ifdef ASLD
|
||||
#define H_GLOBAL (2*H_SIZE) /* external symbol headers */
|
||||
#define H_TOTAL (3*H_SIZE)
|
||||
#else
|
||||
#define H_TOTAL (2*H_SIZE)
|
||||
#endif
|
||||
|
||||
/* numeric label table management */
|
||||
#define FB_SIZE 10
|
||||
#define FB_HEAD (0*FB_SIZE)
|
||||
#define FB_TAIL (1*FB_SIZE)
|
||||
#define FB_BACK (2*FB_SIZE)
|
||||
#define FB_FORW (3*FB_SIZE)
|
||||
|
||||
/* miscellaneous */
|
||||
#define KEYDEFINE 0
|
||||
#define DOTGAIN DOTSCT->s_gain
|
||||
|
||||
/* ========== type declarations ========== */
|
||||
|
||||
struct expr_t {
|
||||
short typ;
|
||||
valu_t val;
|
||||
};
|
||||
|
||||
typedef struct expr_t expr_t;
|
||||
|
||||
struct item_t {
|
||||
struct item_t *
|
||||
i_next; /* linked lists with same hash value */
|
||||
short i_type;
|
||||
/*
|
||||
* the i_type field is used for two different purposes:
|
||||
* - the token type for keywords, returned by yylex()
|
||||
* - the symbol type for IDENT and FBSYM tokens
|
||||
*/
|
||||
valu_t i_valu; /* symbol value */
|
||||
char *i_name; /* symbol name */
|
||||
};
|
||||
|
||||
typedef struct item_t item_t;
|
||||
|
||||
struct sect_t {
|
||||
short s_flag; /* some flag bits */
|
||||
addr_t s_base; /* section base */
|
||||
addr_t s_size; /* section size */
|
||||
addr_t s_comm; /* length of commons */
|
||||
addr_t s_zero; /* delayed emit1(0) */
|
||||
addr_t s_lign; /* section alignment */
|
||||
long s_foff; /* section file offset */
|
||||
item_t *s_item; /* points to section name */
|
||||
#ifdef THREE_PASS
|
||||
addr_t s_gain; /* gain in PASS_2 */
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct sect_t sect_t;
|
||||
|
||||
/* ========== flag field bits ========== */
|
||||
|
||||
/* s_flag bits: */
|
||||
#define BASED 1 /* at fixed position */
|
||||
|
||||
/* sflag bits: */
|
||||
#define SYM_EXT 001 /* external symbols */
|
||||
#define SYM_LOC 002 /* local symbols */
|
||||
#define SYM_LAB 004 /* local, compiler-generated labels */
|
||||
#define SYM_SMB 010 /* .symb symbols */
|
||||
#define SYM_LIN 020 /* .line and .file */
|
||||
#define SYM_SCT 040 /* section names */
|
||||
#define SYM_DEF 073 /* default value */
|
||||
|
||||
/*
|
||||
* extra type bits out of S_ETC, internal use only
|
||||
#ifndef DUK
|
||||
* S_COM:
|
||||
* - symbols declared by .comm
|
||||
#endif DUK
|
||||
* S_VAR:
|
||||
* - type not known at end of PASS_1 (S_VAR|S_UND)
|
||||
* - value not known at end of PASS_2 (S_VAR|S_ABS)
|
||||
* S_DOT:
|
||||
* - dot expression
|
||||
*/
|
||||
#ifndef DUK
|
||||
#define S_COM 0x0100
|
||||
#endif DUK
|
||||
#define S_VAR 0x0200
|
||||
#define S_DOT 0x0400
|
||||
/* should be tested by preprocessor
|
||||
* due to error in preprocessor it cannot
|
||||
* test performed at runtime now
|
||||
* #if (S_ETC|S_COM|S_VAR|S_DOT) != S_ETC
|
||||
* incorrect type bits
|
||||
* #endif
|
||||
*/
|
||||
|
||||
/* parts of the a.out file */
|
||||
#define PARTEMIT 0
|
||||
#define PARTRELO 1
|
||||
#define PARTNAME 2
|
||||
#define PARTCHAR 3
|
||||
#define PARTS 4
|
||||
|
||||
#ifdef AOUTSEEK
|
||||
#define AOUTPART(p) if(aoutpart!=p){aoutpart=p;fseek(aoutfile,aoutseek[p],0);}
|
||||
#define AOUTPUTC(c,p) {putc(c,aoutfile);aoutseek[p]++;if(ferror(aoutfile))werror();}
|
||||
#else
|
||||
#define AOUTPART(p) /* empty */
|
||||
#define AOUTPUTC(c,p) {putc(c,aoutfile[p]);if(ferror(aoutfile[p]))werror();}
|
||||
#endif
|
||||
@@ -1,122 +0,0 @@
|
||||
/* @(#)comm1.h 1.5 */
|
||||
/*
|
||||
* variable declarations
|
||||
*/
|
||||
|
||||
#ifdef extern
|
||||
#define INIT(x) = x
|
||||
#else
|
||||
#define INIT(x) /* empty */
|
||||
#endif
|
||||
|
||||
extern short pass INIT(PASS_1);
|
||||
/* PASS 1, 2 or 3 */
|
||||
extern short peekc; /* push back symbol (PASS_1) */
|
||||
extern short unresolved; /* number of unresolved references */
|
||||
extern short lineno; /* input line number */
|
||||
extern short hllino; /* high-level language line number */
|
||||
extern short nerrors; /* terminate at end of pass if set */
|
||||
extern short sflag INIT(SYM_DEF);
|
||||
/* -s option (symbol table info) */
|
||||
extern char *progname; /* for error messages */
|
||||
extern char *modulename; /* for error messages */
|
||||
|
||||
#ifdef ASLD
|
||||
extern short archmode; /* scanning archives */
|
||||
extern long archsize; /* size of individual archive entries */
|
||||
#else
|
||||
extern short uflag; /* if 1 make undefineds extern */
|
||||
/* symbol table index for last S_UND */
|
||||
#endif
|
||||
|
||||
#ifdef LISTING
|
||||
extern short dflag; /* -d option (list mode) */
|
||||
#endif
|
||||
|
||||
#ifdef ASLD
|
||||
#ifdef RELOCATION
|
||||
extern short rflag; /* -r option (relocation info) */
|
||||
#endif RELOCATION
|
||||
#else
|
||||
#define rflag 1
|
||||
extern valu_t relonami;
|
||||
#endif ASLD
|
||||
|
||||
#ifdef THREE_PASS
|
||||
extern short bflag; /* -b option (no optimizations) */
|
||||
#endif
|
||||
|
||||
extern char *aoutpath INIT("a.out");
|
||||
extern char temppath[50];
|
||||
|
||||
extern FILE *input;
|
||||
extern FILE *tempfile;
|
||||
|
||||
#ifdef AOUTSEEK
|
||||
extern FILE *aoutfile;
|
||||
extern int aoutpart INIT(-1);
|
||||
extern long aoutseek[PARTS];
|
||||
#else
|
||||
extern FILE *aoutfile[PARTS];
|
||||
#endif
|
||||
|
||||
extern char stringbuf[STRINGMAX];
|
||||
/* contains last string value */
|
||||
|
||||
extern sect_t sect[SECTMAX];
|
||||
|
||||
/*
|
||||
* specials for the location counter
|
||||
*/
|
||||
extern sect_t *DOTSCT; /* §[DOTTYP-S_MIN] or NULL */
|
||||
extern addr_t DOTVAL; /* DOTSCT->s_size + DOTSCT->s_base */
|
||||
extern short DOTTYP; /* S_MIN..S_MAX or S_UND */
|
||||
|
||||
extern item_t *hashtab[H_TOTAL];
|
||||
extern short hashindex; /* see item_search() */
|
||||
|
||||
extern item_t *fb_ptr[4*FB_SIZE];
|
||||
|
||||
#ifdef THREE_PASS
|
||||
extern char bittab[BITMAX>>3];
|
||||
/* one bit per small-large decision */
|
||||
extern short nbits; /* number of decisions so far */
|
||||
#endif
|
||||
|
||||
#ifdef LISTING
|
||||
extern short listmode; /* -d option for current pass */
|
||||
extern short listtemp; /* listmode if .list seen */
|
||||
extern short listflag; /* copied from listtemp at '\n' */
|
||||
extern short listcolm; /* column on output */
|
||||
extern short listeoln INIT(1);
|
||||
/* set by endline, tested by emit1 */
|
||||
extern FILE *listfile; /* copy of source text */
|
||||
extern char listpath[50];
|
||||
#endif
|
||||
|
||||
#ifndef extern
|
||||
extern item_t keytab[];
|
||||
extern struct outhead outhead;
|
||||
#endif
|
||||
|
||||
/* forward function declarations */
|
||||
extern char *libname();
|
||||
extern char *readident();
|
||||
extern char *remember();
|
||||
extern item_t *fb_shift();
|
||||
extern item_t *fb_alloc();
|
||||
extern item_t *item_alloc();
|
||||
extern item_t *item_search();
|
||||
extern valu_t load();
|
||||
extern FILE *ffcreat();
|
||||
extern FILE *fftemp();
|
||||
|
||||
/* some library functions used */
|
||||
extern long atol();
|
||||
extern char *mktemp();
|
||||
extern char *sbrk();
|
||||
extern char *getenv();
|
||||
|
||||
/* ========== Machine dependent C declarations ========== */
|
||||
|
||||
#include "mach1.c"
|
||||
@@ -1,424 +0,0 @@
|
||||
/* @(#)comm2.y 1.7 */
|
||||
|
||||
/*
|
||||
* delay inclusion of machine dependent stuff (see comm0.h)
|
||||
*/
|
||||
#define _include #include
|
||||
|
||||
%{
|
||||
#include "comm0.h"
|
||||
#include "comm1.h"
|
||||
%}
|
||||
|
||||
/* ========== Machine independent Yacc definitions ========== */
|
||||
|
||||
%union {
|
||||
word_t y_word;
|
||||
valu_t y_valu;
|
||||
expr_t y_expr;
|
||||
item_t *y_item;
|
||||
#ifdef ASLD
|
||||
char *y_strp;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef ASLD
|
||||
%token <y_strp> MODULE
|
||||
#endif
|
||||
%token STRING
|
||||
%token <y_item> IDENT
|
||||
%token <y_item> FBSYM
|
||||
%token <y_valu> CODE1
|
||||
%token <y_valu> CODE2
|
||||
%token <y_valu> CODE4
|
||||
%token NUMBER0 /* keep NUMBER* in this order */
|
||||
%token NUMBER1
|
||||
%token NUMBER2
|
||||
%token NUMBER3
|
||||
%token <y_valu> NUMBER
|
||||
%token DOT
|
||||
%token EXTERN
|
||||
%token <y_word> DATA
|
||||
%token <y_word> ASCII
|
||||
%token SECTION
|
||||
%token COMMON
|
||||
%token BASE
|
||||
%token SYMB
|
||||
%token ALIGN
|
||||
%token ASSERT
|
||||
%token SPACE
|
||||
%token <y_word> LINE
|
||||
%token FILe
|
||||
%token <y_word> LIST
|
||||
%token OP_EQ
|
||||
%token OP_NE
|
||||
%token OP_LE
|
||||
%token OP_GE
|
||||
%token OP_LL
|
||||
%token OP_RR
|
||||
%token OP_OO
|
||||
%token OP_AA
|
||||
|
||||
%left OP_OO
|
||||
%left OP_AA
|
||||
%left '|'
|
||||
%left '^'
|
||||
%left '&'
|
||||
%left OP_EQ OP_NE
|
||||
%left '<' '>' OP_LE OP_GE
|
||||
%left OP_LL OP_RR
|
||||
%left '+' '-'
|
||||
%left '*' '/' '%'
|
||||
%nonassoc '~'
|
||||
|
||||
%type <y_valu> absexp optabs1 optabs2
|
||||
%type <y_expr> expr
|
||||
%type <y_item> id_fb
|
||||
|
||||
/* ========== Machine dependent Yacc definitions ========== */
|
||||
|
||||
#include "mach2.c"
|
||||
|
||||
%%
|
||||
|
||||
/* ========== Machine independent rules ========== */
|
||||
|
||||
#ifdef LISTING
|
||||
#define LISTLINE(n) listline(n)
|
||||
#else
|
||||
#define LISTLINE(n) /* empty */
|
||||
#endif LISTING
|
||||
|
||||
#ifdef ASLD
|
||||
#define RELODONE /* empty */
|
||||
#else
|
||||
#define RELODONE assert(relonami == 0)
|
||||
#endif
|
||||
|
||||
program : /* empty */
|
||||
#ifdef ASLD
|
||||
| program MODULE /* not in PASS_1 */
|
||||
{ newmodule($2);}
|
||||
#endif
|
||||
| program IDENT ':'
|
||||
{ newident($2, DOTTYP); newlabel($2);}
|
||||
| program NUMBER ':'
|
||||
{ if ($2 < 0 || $2 > 9) {
|
||||
serror("bad f/b label");
|
||||
$2 = 0;
|
||||
}
|
||||
newlabel(fb_shift((int)$2));
|
||||
}
|
||||
| program CODE1
|
||||
{ emit1((char)$2); LISTLINE(0);}
|
||||
| program CODE2
|
||||
{ emit2((short)$2); LISTLINE(0);}
|
||||
| program CODE4
|
||||
{ emit4((long)$2); LISTLINE(0);}
|
||||
| program operation ';'
|
||||
| program operation '\n'
|
||||
{ lineno++; LISTLINE(1); RELODONE;}
|
||||
| program '#' NUMBER STRING '\n'
|
||||
{ lineno++; LISTLINE(1); RELODONE;}
|
||||
| program error '\n'
|
||||
{ serror("syntax error"); yyerrok;
|
||||
lineno++; LISTLINE(1); RELODONE;
|
||||
}
|
||||
;
|
||||
#undef LISTLINE
|
||||
#undef RELODONE
|
||||
operation
|
||||
: /* empty */
|
||||
| IDENT '=' expr
|
||||
{
|
||||
#ifdef LISTING
|
||||
if (listflag & 1)
|
||||
listcolm += printx(VALWIDTH, $3.val);
|
||||
#endif
|
||||
newequate($1, $3.typ);
|
||||
store($1, $3.val);
|
||||
}
|
||||
#ifdef LISTING
|
||||
| LIST
|
||||
{ if ($1)
|
||||
listtemp = listmode;
|
||||
else if ((dflag & 01000) == 0)
|
||||
listtemp = 0;
|
||||
}
|
||||
#endif
|
||||
| SECTION IDENT
|
||||
{ newsect($2);}
|
||||
| COMMON IDENT ',' absexp
|
||||
{ newcomm($2, $4);}
|
||||
| BASE absexp
|
||||
{ if (pass == PASS_1) newbase($2);}
|
||||
| ASSERT expr
|
||||
{ if ($2.val == 0 && pass == PASS_3)
|
||||
warning("assertion failed");
|
||||
}
|
||||
| SYMB STRING ',' expr optabs2 optabs2
|
||||
{ if ((sflag & SYM_SMB) && PASS_SYMB) {
|
||||
#ifndef ASLD
|
||||
if (
|
||||
pass == PASS_3
|
||||
&&
|
||||
($4.typ & S_TYP) == S_UND
|
||||
) {
|
||||
serror("expression undefined");
|
||||
relonami = -1;
|
||||
}
|
||||
#endif
|
||||
newsymb(
|
||||
stringbuf+1,
|
||||
(short)(
|
||||
($4.typ & (S_EXT|S_TYP))
|
||||
|
|
||||
((ushort)$5<<8)
|
||||
),
|
||||
(short)$6,
|
||||
$4.val
|
||||
);
|
||||
}
|
||||
}
|
||||
| LINE optabs1
|
||||
{ if ((sflag & SYM_LIN) && PASS_SYMB) {
|
||||
if ($2)
|
||||
hllino = (short)$2;
|
||||
else
|
||||
hllino++;
|
||||
newsymb(
|
||||
(char *)0,
|
||||
(short)(DOTTYP | S_LIN),
|
||||
(short)hllino,
|
||||
(valu_t)DOTVAL
|
||||
);
|
||||
}
|
||||
}
|
||||
| FILe STRING
|
||||
{ if ((sflag & SYM_LIN) && PASS_SYMB) {
|
||||
hllino = 0;
|
||||
newsymb(
|
||||
stringbuf+1,
|
||||
(short)(DOTTYP | S_FIL),
|
||||
(short)0,
|
||||
(valu_t)DOTVAL
|
||||
);
|
||||
}
|
||||
}
|
||||
| EXTERN externlist
|
||||
| ALIGN optabs1
|
||||
{ align($2);}
|
||||
| SPACE absexp
|
||||
{ if (DOTSCT == NULL)
|
||||
nosect();
|
||||
DOTVAL += $2;
|
||||
DOTSCT->s_zero += $2;
|
||||
}
|
||||
| DATA datalist
|
||||
| ASCII STRING
|
||||
{ emitstr($1);}
|
||||
;
|
||||
externlist
|
||||
: IDENT
|
||||
{ $1->i_type |= S_EXT;}
|
||||
| externlist ',' IDENT
|
||||
{ $3->i_type |= S_EXT;}
|
||||
;
|
||||
datalist
|
||||
: expr
|
||||
{
|
||||
#ifdef RELOCATION
|
||||
if (rflag != 0 && PASS_RELO)
|
||||
#ifdef DUK
|
||||
#ifdef BYTES_REVERSED
|
||||
#ifdef WORDS_REVERSED
|
||||
newrelo($1.typ,
|
||||
(int)$<y_word>0 | RELBR | RELWR
|
||||
);
|
||||
#else WORDS_REVERSED
|
||||
newrelo($1.typ, (int)$<y_word>0|RELBR);
|
||||
#endif WORDS_REVERSED
|
||||
#else BYTES_REVERSED
|
||||
#ifdef WORDS_REVERSED
|
||||
newrelo($1.typ, (int)$<y_word>0|RELWR);
|
||||
#else WORDS_REVERSED
|
||||
newrelo($1.typ, (int)$<y_word>0);
|
||||
#endif WORDS_REVERSED
|
||||
#endif BYTES_REVERSED
|
||||
#else DUK
|
||||
newrelo($1.typ, (int)$<y_word>0);
|
||||
#endif DUK
|
||||
#endif
|
||||
emitx($1.val, (int)$<y_word>0);
|
||||
}
|
||||
| datalist ',' expr
|
||||
{
|
||||
#ifdef RELOCATION
|
||||
if (rflag != 0 && PASS_RELO)
|
||||
#ifdef DUK
|
||||
#ifdef BYTES_REVERSED
|
||||
#ifdef WORDS_REVERSED
|
||||
newrelo($3.typ,
|
||||
(int)$<y_word>0 | RELBR | RELWR
|
||||
);
|
||||
#else WORDS_REVERSED
|
||||
newrelo($3.typ, (int)$<y_word>0|RELBR);
|
||||
#endif WORDS_REVERSED
|
||||
#else BYTES_REVERSED
|
||||
#ifdef WORDS_REVERSED
|
||||
newrelo($3.typ, (int)$<y_word>0|RELWR);
|
||||
#else WORDS_REVERSED
|
||||
newrelo($3.typ, (int)$<y_word>0);
|
||||
#endif WORDS_REVERSED
|
||||
#endif BYTES_REVERSED
|
||||
#else DUK
|
||||
newrelo($3.typ, (int)$<y_word>0);
|
||||
#endif DUK
|
||||
#endif
|
||||
emitx($3.val, (int)$<y_word>0);
|
||||
}
|
||||
;
|
||||
expr : error
|
||||
{ serror("expr syntax err");
|
||||
$$.val = 0; $$.typ = S_UND;
|
||||
}
|
||||
| NUMBER
|
||||
{ $$.val = $1; $$.typ = S_ABS;}
|
||||
| id_fb
|
||||
{ $$.val = load($1);
|
||||
$$.typ = $1->i_type & ~S_EXT;
|
||||
}
|
||||
| STRING
|
||||
{ if (stringbuf[0] != 1)
|
||||
serror("too many chars");
|
||||
$$.val = stringbuf[1];
|
||||
$$.typ = S_ABS;
|
||||
}
|
||||
| ASC_LPAR expr ASC_RPAR
|
||||
{ $$ = $2;}
|
||||
| expr OP_OO expr
|
||||
{ $$.val = ($1.val || $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, 0);
|
||||
}
|
||||
| expr OP_AA expr
|
||||
{ $$.val = ($1.val && $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, 0);
|
||||
}
|
||||
| expr '|' expr
|
||||
{ $$.val = ($1.val | $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, 0);
|
||||
}
|
||||
| expr '^' expr
|
||||
{ $$.val = ($1.val ^ $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, 0);
|
||||
}
|
||||
| expr '&' expr
|
||||
{ $$.val = ($1.val & $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, 0);
|
||||
}
|
||||
| expr OP_EQ expr
|
||||
{ $$.val = ($1.val == $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, '>');
|
||||
}
|
||||
| expr OP_NE expr
|
||||
{ $$.val = ($1.val != $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, '>');
|
||||
}
|
||||
| expr '<' expr
|
||||
{ $$.val = ($1.val < $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, '>');
|
||||
}
|
||||
| expr '>' expr
|
||||
{ $$.val = ($1.val > $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, '>');
|
||||
}
|
||||
| expr OP_LE expr
|
||||
{ $$.val = ($1.val <= $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, '>');
|
||||
}
|
||||
| expr OP_GE expr
|
||||
{ $$.val = ($1.val >= $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, '>');
|
||||
}
|
||||
| expr OP_RR expr
|
||||
{ $$.val = ($1.val >> $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, 0);
|
||||
}
|
||||
| expr OP_LL expr
|
||||
{ $$.val = ($1.val << $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, 0);
|
||||
}
|
||||
| expr '+' expr
|
||||
{ $$.val = ($1.val + $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, '+');
|
||||
}
|
||||
| expr '-' expr
|
||||
{ $$.val = ($1.val - $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, '-');
|
||||
}
|
||||
| expr '*' expr
|
||||
{ $$.val = ($1.val * $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, 0);
|
||||
}
|
||||
| expr '/' expr
|
||||
{ if ($3.val == 0) {
|
||||
if (pass == PASS_3)
|
||||
serror("divide by zero");
|
||||
$$.val = 0;
|
||||
} else
|
||||
$$.val = ($1.val / $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, 0);
|
||||
}
|
||||
| expr '%' expr
|
||||
{ if ($3.val == 0) {
|
||||
if (pass == PASS_3)
|
||||
serror("divide by zero");
|
||||
$$.val = 0;
|
||||
} else
|
||||
$$.val = ($1.val % $3.val);
|
||||
$$.typ = combine($1.typ, $3.typ, 0);
|
||||
}
|
||||
| '+' expr %prec '*'
|
||||
{ $$.val = $2.val;
|
||||
$$.typ = combine(S_ABS, $2.typ, 0);
|
||||
}
|
||||
| '-' expr %prec '*'
|
||||
{ $$.val = -$2.val;
|
||||
$$.typ = combine(S_ABS, $2.typ, 0);
|
||||
}
|
||||
| '~' expr
|
||||
{ $$.val = ~$2.val;
|
||||
$$.typ = combine(S_ABS, $2.typ, 0);
|
||||
}
|
||||
| DOT
|
||||
{ $$.val = DOTVAL;
|
||||
$$.typ = DOTTYP|S_DOT;
|
||||
}
|
||||
;
|
||||
id_fb : IDENT
|
||||
| FBSYM
|
||||
;
|
||||
absexp : expr
|
||||
{ if (($1.typ & ~S_EXT) != S_ABS)
|
||||
serror("must be absolute");
|
||||
$$ = $1.val;
|
||||
}
|
||||
;
|
||||
optabs1
|
||||
: /* empty */
|
||||
{ $$ = 0;}
|
||||
| absexp
|
||||
{ $$ = $1;}
|
||||
;
|
||||
optabs2
|
||||
: /* empty */
|
||||
{ $$ = 0;}
|
||||
| ',' absexp
|
||||
{ $$ = $2;}
|
||||
;
|
||||
|
||||
/* ========== Machine dependent rules ========== */
|
||||
|
||||
#include "mach4.c"
|
||||
|
||||
%%
|
||||
@@ -1,50 +0,0 @@
|
||||
/* @(#)comm3.c 1.1 */
|
||||
/*
|
||||
* storage allocation for variables
|
||||
*/
|
||||
|
||||
#include "comm0.h"
|
||||
|
||||
#define extern /* empty, to force storage allocation */
|
||||
|
||||
#include "comm1.h"
|
||||
|
||||
struct outhead outhead = {
|
||||
O_MAGIC, O_STAMP, 0
|
||||
#ifndef DUK
|
||||
#ifdef BYTES_REVERSED
|
||||
| HF_BREV
|
||||
#endif
|
||||
#ifdef WORDS_REVERSED
|
||||
| HF_WREV
|
||||
#endif
|
||||
#endif DUK
|
||||
};
|
||||
|
||||
#include "y.tab.h"
|
||||
|
||||
item_t keytab[] = {
|
||||
0, EXTERN, 0, ".define",
|
||||
0, EXTERN, 0, ".extern",
|
||||
0, DOT, 0, ".",
|
||||
0, DATA, 1, ".data1",
|
||||
0, DATA, 2, ".data2",
|
||||
0, DATA, 4, ".data4",
|
||||
0, ASCII, 0, ".ascii",
|
||||
0, ASCII, 1, ".asciz",
|
||||
0, ALIGN, 0, ".align",
|
||||
0, ASSERT, 0, ".assert",
|
||||
0, SPACE, 0, ".space",
|
||||
0, COMMON, 0, ".comm",
|
||||
0, SECTION, 0, ".sect",
|
||||
0, BASE, 0, ".base",
|
||||
0, SYMB, 0, ".symb",
|
||||
0, LINE, 0, ".line",
|
||||
0, FILe, 0, ".file",
|
||||
#ifdef LISTING
|
||||
0, LIST, 0, ".nolist",
|
||||
0, LIST, 1, ".list",
|
||||
#endif
|
||||
#include "mach3.c"
|
||||
0, 0, 0, 0
|
||||
};
|
||||
@@ -1,539 +0,0 @@
|
||||
/* @(#)comm4.c 1.6 */
|
||||
/*
|
||||
* Micro processor assembler framework written by
|
||||
* Johan Stevenson, Vrije Universiteit, Amsterdam
|
||||
* modified by
|
||||
* Johan Stevenson, Han Schaminee and Hans de Vries
|
||||
* Philips S&I, T&M, PMDS, Eindhoven
|
||||
*/
|
||||
|
||||
#include "comm0.h"
|
||||
#include "comm1.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
/* ========== Machine independent C routines ========== */
|
||||
|
||||
stop() {
|
||||
#if DEBUG < 2
|
||||
unlink(temppath);
|
||||
#ifdef LISTING
|
||||
unlink(listpath);
|
||||
#endif
|
||||
#endif
|
||||
exit(nerrors != 0);
|
||||
}
|
||||
|
||||
main(argc, argv)
|
||||
char **argv;
|
||||
{
|
||||
register char *p;
|
||||
register i;
|
||||
static char sigs[] = {
|
||||
SIGHUP, SIGINT, SIGQUIT, SIGTERM, 0
|
||||
};
|
||||
|
||||
/* this test should be performed by the
|
||||
* preprocessor, but it cannot
|
||||
*/
|
||||
if ((S_ETC|S_COM|S_VAR|S_DOT) != S_ETC)
|
||||
fatal("incorrect type bits");
|
||||
|
||||
progname = *argv++; argc--;
|
||||
for (p = sigs; i = *p++; )
|
||||
if (signal(i, SIG_IGN) != SIG_IGN)
|
||||
signal(i, stop);
|
||||
for (i = 0; i < argc; i++) {
|
||||
p = argv[i];
|
||||
if (*p++ != '-')
|
||||
continue;
|
||||
switch (*p++) {
|
||||
case 'o':
|
||||
if (*p != NULL) {
|
||||
aoutpath = p;
|
||||
break;
|
||||
}
|
||||
argv[i] = 0;
|
||||
if (++i >= argc)
|
||||
fatal("-o needs filename");
|
||||
aoutpath = argv[i];
|
||||
break;
|
||||
case 'd':
|
||||
#ifdef LISTING
|
||||
dflag = 0;
|
||||
while (*p >= '0' && *p <= '7')
|
||||
dflag = (dflag << 3) + *p++ - '0';
|
||||
if ((dflag & 0777) == 0)
|
||||
dflag |= 0700;
|
||||
dflag &= ~4;
|
||||
#endif
|
||||
break;
|
||||
case 's':
|
||||
sflag = 0;
|
||||
while (*p >= '0' && *p <= '7')
|
||||
sflag = (sflag << 3) + *p++ - '0';
|
||||
break;
|
||||
case 'r':
|
||||
#ifdef RELOCATION
|
||||
#ifdef ASLD
|
||||
rflag = 1;
|
||||
#endif ASLD
|
||||
#endif RELOCATION
|
||||
break;
|
||||
case 'b':
|
||||
#ifdef THREE_PASS
|
||||
bflag = 1;
|
||||
#endif
|
||||
break;
|
||||
#ifndef ASLD
|
||||
case 'u':
|
||||
case '\0':
|
||||
uflag = 1;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
argv[i] = 0;
|
||||
}
|
||||
#ifdef RELOCATION
|
||||
if (rflag)
|
||||
sflag |= SYM_SCT;
|
||||
#endif RELOCATION
|
||||
pass_1(argc, argv);
|
||||
#ifdef THREE_PASS
|
||||
pass_23(PASS_2);
|
||||
#endif
|
||||
pass_23(PASS_3);
|
||||
stop();
|
||||
}
|
||||
|
||||
/* ---------- pass 1: arguments, modules, archives ---------- */
|
||||
|
||||
pass_1(argc, argv)
|
||||
char **argv;
|
||||
{
|
||||
register i;
|
||||
register char *p;
|
||||
register item_t *ip;
|
||||
#ifdef ASLD
|
||||
char armagic[SZMAGIC];
|
||||
#else
|
||||
register nfile = 0;
|
||||
#endif
|
||||
|
||||
tempfile = fftemp(temppath, "asTXXXXXX");
|
||||
#ifdef LISTING
|
||||
listmode = dflag;
|
||||
if (listmode & 0440)
|
||||
listfile = fftemp(listpath, "asLXXXXXX");
|
||||
#endif
|
||||
for (ip = keytab; ip->i_type; ip++)
|
||||
item_insert(ip, H_KEY+hash(ip->i_name));
|
||||
machstart(PASS_1);
|
||||
while (--argc >= 0) {
|
||||
p = *argv++;
|
||||
if (p == 0)
|
||||
continue;
|
||||
#ifdef ASLD
|
||||
if (p[0] == '-' && p[1] == '\0') {
|
||||
input = stdin;
|
||||
parse("STDIN");
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
if (nfile != 0)
|
||||
fatal("second source file %s", p);
|
||||
nfile++;
|
||||
#endif
|
||||
if ((input = fopen(p, "r")) == NULL)
|
||||
fatal("can't open %s", p);
|
||||
#ifdef ASLD
|
||||
if (
|
||||
fread(armagic, SZMAGIC, 1, input) == 1
|
||||
&&
|
||||
strncmp(armagic, ARMAGIC, SZMAGIC) == 0
|
||||
) {
|
||||
archive();
|
||||
fclose(input);
|
||||
continue;
|
||||
}
|
||||
rewind(input);
|
||||
#endif
|
||||
parse(p);
|
||||
fclose(input);
|
||||
}
|
||||
commfinish();
|
||||
machfinish(PASS_1);
|
||||
#ifdef ASLD
|
||||
if (unresolved) {
|
||||
nerrors++;
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "unresolved references:\n");
|
||||
for (i = 0; i < H_SIZE; i++) {
|
||||
ip = hashtab[H_GLOBAL+i];
|
||||
while (ip != 0) {
|
||||
if ((ip->i_type & (S_EXT|S_TYP)) == (S_EXT|S_UND))
|
||||
fprintf(stderr, "\t%s\n", ip->i_name);
|
||||
ip = ip->i_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (unresolved)
|
||||
outhead.oh_flags |= HF_LINK;
|
||||
if (nfile == 0)
|
||||
fatal("no source file");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ASLD
|
||||
archive()
|
||||
{
|
||||
register long offset;
|
||||
register i;
|
||||
register long modsize;
|
||||
char modhead[SZMHEAD];
|
||||
|
||||
archmode++;
|
||||
offset = SZMAGIC;
|
||||
for (;;) {
|
||||
if (unresolved == 0)
|
||||
break;
|
||||
fseek(input, offset, 0);
|
||||
if (fread(modhead, SZMHEAD, 1, input) != 1)
|
||||
break;
|
||||
if (
|
||||
strncmp(&modhead[OFF_BEG], STR_BEG, LEN_BEG)
|
||||
||
|
||||
strncmp(&modhead[OFF_END], STR_END, LEN_END)
|
||||
)
|
||||
fatal("bad archive");
|
||||
offset += SZMHEAD;
|
||||
modsize = atol(&modhead[OFF_SIZ]);
|
||||
archsize = modsize;
|
||||
if (needed()) {
|
||||
fseek(input, offset, 0);
|
||||
archsize = modsize;
|
||||
for (i = 0; i < LEN_NAM; i++)
|
||||
if (modhead[OFF_NAM+i] == ' ')
|
||||
break;
|
||||
modhead[OFF_NAM+i] = '\0';
|
||||
parse(remember(&modhead[OFF_NAM]));
|
||||
}
|
||||
offset += modsize;
|
||||
}
|
||||
archmode = 0;
|
||||
}
|
||||
|
||||
needed()
|
||||
{
|
||||
register c, first;
|
||||
register item_t *ip;
|
||||
register need;
|
||||
|
||||
#ifdef LISTING
|
||||
register save;
|
||||
|
||||
save = listflag; listflag = 0;
|
||||
#endif
|
||||
need = 0;
|
||||
peekc = -1;
|
||||
first = 1;
|
||||
for (;;) {
|
||||
c = nextchar();
|
||||
if (c == '\n') {
|
||||
first = 1;
|
||||
continue;
|
||||
}
|
||||
if (c == ' ' || c == '\t' || c == ',')
|
||||
continue;
|
||||
if (ISALPHA(c) == 0)
|
||||
break;
|
||||
if ((ip = item_search(readident(c))) == 0) {
|
||||
if (first)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if (first) {
|
||||
if (ip != &keytab[KEYDEFINE])
|
||||
break;
|
||||
first = 0;
|
||||
}
|
||||
if ((ip->i_type & S_TYP) == S_UND) {
|
||||
need++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef LISTING
|
||||
listflag = save;
|
||||
#endif
|
||||
return(need);
|
||||
}
|
||||
#endif ASLD
|
||||
|
||||
parse(s)
|
||||
char *s;
|
||||
{
|
||||
register i;
|
||||
register item_t *ip;
|
||||
register char *p;
|
||||
|
||||
for (p = s; *p; )
|
||||
if (*p++ == '/')
|
||||
s = p;
|
||||
#ifdef ASLD
|
||||
yylval.y_strp = s;
|
||||
putval(MODULE);
|
||||
#endif
|
||||
for (i = 0; i < FB_SIZE; i++)
|
||||
fb_ptr[FB_BACK+i] = 0;
|
||||
newmodule(s);
|
||||
peekc = -1;
|
||||
yyparse();
|
||||
/*
|
||||
* Check for undefined symbols
|
||||
*/
|
||||
#ifdef ASLD
|
||||
for (i = 0; i < H_SIZE; i++) {
|
||||
while (ip = hashtab[H_LOCAL+i]) {
|
||||
/*
|
||||
* cleanup local queue
|
||||
*/
|
||||
hashtab[H_LOCAL+i] = ip->i_next;
|
||||
/*
|
||||
* make undefined references extern
|
||||
*/
|
||||
if ((ip->i_type & (S_VAR|S_TYP)) == S_UND)
|
||||
ip->i_type |= S_EXT;
|
||||
/*
|
||||
* relink externals in global queue
|
||||
*/
|
||||
if (ip->i_type & S_EXT)
|
||||
item_insert(ip, H_GLOBAL+i);
|
||||
}
|
||||
}
|
||||
#else
|
||||
for (i = 0; i < H_SIZE; i++) {
|
||||
for (ip = hashtab[H_LOCAL+i]; ip; ip = ip->i_next) {
|
||||
if (ip->i_type & S_EXT)
|
||||
continue;
|
||||
if (ip->i_type != S_UND)
|
||||
continue;
|
||||
if (uflag == 0)
|
||||
serror("undefined symbol %s", ip->i_name);
|
||||
ip->i_type |= S_EXT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Check for undefined numeric labels
|
||||
*/
|
||||
for (i = 0; i < FB_SIZE; i++) {
|
||||
if ((ip = fb_ptr[FB_FORW+i]) == 0)
|
||||
continue;
|
||||
serror("undefined label %d", i);
|
||||
fb_ptr[FB_FORW+i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pass_23(n)
|
||||
{
|
||||
register i;
|
||||
#ifdef ASLD
|
||||
register addr_t base = 0;
|
||||
#endif
|
||||
register sect_t *sp;
|
||||
|
||||
if (nerrors)
|
||||
stop();
|
||||
pass = n;
|
||||
#ifdef LISTING
|
||||
listmode >>= 3;
|
||||
if (listmode & 4)
|
||||
ffreopen(listpath, listfile);
|
||||
listeoln = 1;
|
||||
#endif
|
||||
#ifdef THREE_PASS
|
||||
nbits = 0;
|
||||
#endif
|
||||
for (i = 0; i < FB_SIZE; i++)
|
||||
fb_ptr[FB_FORW+i] = fb_ptr[FB_HEAD+i];
|
||||
outhead.oh_nemit = 0;
|
||||
for (sp = sect; sp < §[outhead.oh_nsect]; sp++) {
|
||||
#ifdef ASLD
|
||||
if (sp->s_flag & BASED) {
|
||||
base = sp->s_base;
|
||||
if (base % sp->s_lign)
|
||||
fatal("base not aligned");
|
||||
} else {
|
||||
base += (sp->s_lign - 1);
|
||||
base -= (base % sp->s_lign);
|
||||
sp->s_base = base;
|
||||
}
|
||||
base += sp->s_size;
|
||||
base += sp->s_comm;
|
||||
#endif
|
||||
outhead.oh_nemit += sp->s_size - sp->s_zero;
|
||||
}
|
||||
if (pass == PASS_3)
|
||||
setupoutput();
|
||||
for (sp = sect; sp < §[outhead.oh_nsect]; sp++) {
|
||||
sp->s_size = 0;
|
||||
sp->s_zero = 0;
|
||||
#ifdef THREE_PASS
|
||||
sp->s_gain = 0;
|
||||
#endif
|
||||
}
|
||||
machstart(n);
|
||||
#ifndef ASLD
|
||||
newmodule(modulename);
|
||||
#endif ASLD
|
||||
ffreopen(temppath, tempfile);
|
||||
yyparse();
|
||||
commfinish();
|
||||
machfinish(n);
|
||||
}
|
||||
|
||||
newmodule(s)
|
||||
char *s;
|
||||
{
|
||||
switchsect(S_UND);
|
||||
modulename = s;
|
||||
lineno = 1;
|
||||
if ((sflag & (SYM_EXT|SYM_LOC|SYM_LAB)) && PASS_SYMB)
|
||||
newsymb(s, S_MOD, (short)0, (valu_t)0);
|
||||
#ifdef LISTING
|
||||
listtemp = 0;
|
||||
if (dflag & 01000)
|
||||
listtemp = listmode;
|
||||
listflag = listtemp;
|
||||
#endif
|
||||
}
|
||||
|
||||
setupoutput()
|
||||
{
|
||||
register sect_t *sp;
|
||||
register long off;
|
||||
struct outsect outsect;
|
||||
|
||||
#ifdef AOUTSEEK
|
||||
#define AOUTseek(p,o) {aoutseek[p]=o;}
|
||||
aoutfile = ffcreat(aoutpath);
|
||||
#else
|
||||
#define AOUTseek(p,o) {fseek(aoutfile[p],o,0);}
|
||||
aoutfile[PARTEMIT]=ffcreat(aoutpath);
|
||||
#ifdef RELOCATION
|
||||
aoutfile[PARTRELO]=ffcreat(aoutpath);
|
||||
#endif
|
||||
aoutfile[PARTNAME]=ffcreat(aoutpath);
|
||||
aoutfile[PARTCHAR]=ffcreat(aoutpath);
|
||||
#endif
|
||||
/*
|
||||
* header generation
|
||||
*/
|
||||
AOUTseek(PARTEMIT, 0);
|
||||
putofmt((char *)&outhead, SF_HEAD, PARTEMIT);
|
||||
/*
|
||||
* section table generation
|
||||
*/
|
||||
off = SZ_HEAD;
|
||||
off += (long)outhead.oh_nsect * SZ_SECT;
|
||||
for (sp = sect; sp < §[outhead.oh_nsect]; sp++) {
|
||||
sp->s_foff = off;
|
||||
outsect.os_base = SETBASE(sp);
|
||||
outsect.os_size = sp->s_size + sp->s_comm;
|
||||
outsect.os_foff = sp->s_foff;
|
||||
outsect.os_flen = sp->s_size - sp->s_zero;
|
||||
outsect.os_lign = sp->s_lign;
|
||||
off += outsect.os_flen;
|
||||
putofmt((char *)&outsect, SF_SECT, PARTEMIT);
|
||||
}
|
||||
#ifdef RELOCATION
|
||||
AOUTseek(PARTRELO, off);
|
||||
off += (long)outhead.oh_nrelo * SZ_RELO;
|
||||
#endif
|
||||
if (sflag == 0)
|
||||
return;
|
||||
AOUTseek(PARTNAME, off);
|
||||
off += (long)outhead.oh_nname * SZ_NAME;
|
||||
AOUTseek(PARTCHAR, off);
|
||||
outhead.oh_nchar = off; /* see newsymb() */
|
||||
#undef AOUTseek
|
||||
}
|
||||
|
||||
commfinish()
|
||||
{
|
||||
register i;
|
||||
register item_t *ip;
|
||||
register sect_t *sp;
|
||||
register valu_t addr;
|
||||
|
||||
switchsect(S_UND);
|
||||
#ifdef ASLD
|
||||
/*
|
||||
* assign .comm labels and produce .comm symbol table entries
|
||||
*/
|
||||
for (i = 0; i<H_SIZE; i++)
|
||||
for (ip = hashtab[H_GLOBAL+i]; ip; ip = ip->i_next) {
|
||||
if ((ip->i_type & S_COM) == 0)
|
||||
continue;
|
||||
sp = §[(ip->i_type & S_TYP) - S_MIN];
|
||||
if (pass == PASS_1) {
|
||||
addr = sp->s_size + sp->s_comm;
|
||||
sp->s_comm += ip->i_valu;
|
||||
ip->i_valu = addr;
|
||||
}
|
||||
#ifdef THREE_PASS
|
||||
if (pass == PASS_2)
|
||||
ip->i_valu -= sp->s_gain;
|
||||
#endif
|
||||
if ((sflag & SYM_EXT) && PASS_SYMB)
|
||||
newsymb(
|
||||
ip->i_name,
|
||||
ip->i_type & (S_EXT|S_TYP),
|
||||
(short)0,
|
||||
load(ip)
|
||||
);
|
||||
}
|
||||
#endif
|
||||
if (PASS_SYMB == 0)
|
||||
return;
|
||||
#ifndef ASLD
|
||||
/*
|
||||
* produce symbol table entries for undefined's
|
||||
*/
|
||||
for (i = 0; i<H_SIZE; i++)
|
||||
for (ip = hashtab[H_LOCAL+i]; ip; ip = ip->i_next) {
|
||||
if (ip->i_type != (S_EXT|S_UND))
|
||||
continue;
|
||||
if (pass != PASS_3)
|
||||
/*
|
||||
* save symbol table index
|
||||
* for possible relocation
|
||||
*/
|
||||
ip->i_valu = outhead.oh_nname;
|
||||
if (sflag & SYM_SCT)
|
||||
newsymb(
|
||||
ip->i_name,
|
||||
S_EXT|S_UND,
|
||||
(short)0,
|
||||
(valu_t)0
|
||||
);
|
||||
}
|
||||
#endif ASLD
|
||||
/*
|
||||
* produce symbol table entries for sections
|
||||
*/
|
||||
if (sflag & SYM_SCT)
|
||||
for (sp = sect; sp < §[outhead.oh_nsect]; sp++) {
|
||||
ip = sp->s_item;
|
||||
newsymb(
|
||||
ip->i_name,
|
||||
(short)(ip->i_type | S_SCT),
|
||||
(short)0,
|
||||
load(ip)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,528 +0,0 @@
|
||||
/* @(#)comm5.c 1.1 */
|
||||
|
||||
#include "comm0.h"
|
||||
#include "comm1.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
yylex()
|
||||
{
|
||||
register c;
|
||||
|
||||
if (pass == PASS_1) {
|
||||
/* scan the input file */
|
||||
do
|
||||
c = nextchar();
|
||||
while (isspace(c) && c != '\n');
|
||||
if (ISALPHA(c))
|
||||
c = inident(c);
|
||||
else if (isdigit(c))
|
||||
c = innumber(c);
|
||||
else switch (c) {
|
||||
case '=':
|
||||
case '<':
|
||||
case '>':
|
||||
case '|':
|
||||
case '&':
|
||||
c = induo(c); break;
|
||||
case ASC_SQUO:
|
||||
case ASC_DQUO:
|
||||
c = instring(c); break;
|
||||
case ASC_COMM:
|
||||
do
|
||||
c = nextchar();
|
||||
while (c != '\n' && c != '\0');
|
||||
break;
|
||||
case CTRL('A'):
|
||||
c = CODE1; readcode(1); break;
|
||||
case CTRL('B'):
|
||||
c = CODE2; readcode(2); break;
|
||||
case CTRL('C'):
|
||||
c = CODE4; readcode(4); break;
|
||||
}
|
||||
|
||||
/* produce the intermediate token file */
|
||||
if (c <= 0)
|
||||
return(0);
|
||||
if (c <= 127)
|
||||
putc(c, tempfile);
|
||||
else
|
||||
putval(c);
|
||||
} else {
|
||||
/* read from intermediate token file */
|
||||
c = getc(tempfile);
|
||||
if (c == EOF)
|
||||
return(0);
|
||||
if (c > 127) {
|
||||
c += 128;
|
||||
c = getval(c);
|
||||
}
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
putval(c)
|
||||
{
|
||||
register valu_t v;
|
||||
register n;
|
||||
register char *p;
|
||||
|
||||
assert(c >= 256 && c < 256+128);
|
||||
switch (c) {
|
||||
case CODE1:
|
||||
n = 1; goto putnum;
|
||||
case CODE2:
|
||||
n = 2; goto putnum;
|
||||
case CODE4:
|
||||
n = 4; goto putnum;
|
||||
case NUMBER:
|
||||
v = yylval.y_valu;
|
||||
for (n = 0; n < sizeof(v); n++) {
|
||||
if (v == 0)
|
||||
break;
|
||||
v >>= 8;
|
||||
}
|
||||
c = NUMBER0 + n;
|
||||
putnum:
|
||||
putc(c-128, tempfile);
|
||||
v = yylval.y_valu;
|
||||
while (--n >= 0)
|
||||
putc(v >> (n*8), tempfile);
|
||||
return;
|
||||
case IDENT:
|
||||
case FBSYM:
|
||||
n = sizeof(item_t *);
|
||||
p = (char *) &yylval.y_item; break;
|
||||
#ifdef ASLD
|
||||
case MODULE:
|
||||
n = sizeof(char *);
|
||||
p = (char *) &yylval.y_strp; break;
|
||||
#endif
|
||||
case STRING:
|
||||
p = stringbuf;
|
||||
n = (*p & 0377) + 1; break;
|
||||
case OP_EQ:
|
||||
case OP_NE:
|
||||
case OP_LE:
|
||||
case OP_GE:
|
||||
case OP_LL:
|
||||
case OP_RR:
|
||||
case OP_OO:
|
||||
case OP_AA:
|
||||
n = 0; break;
|
||||
default:
|
||||
n = sizeof(word_t);
|
||||
p = (char *) &yylval.y_word; break;
|
||||
}
|
||||
putc(c-128, tempfile);
|
||||
while (--n >= 0)
|
||||
putc(*p++, tempfile);
|
||||
}
|
||||
|
||||
getval(c)
|
||||
{
|
||||
register n;
|
||||
register valu_t v;
|
||||
register char *p;
|
||||
|
||||
switch (c) {
|
||||
case CODE1:
|
||||
n = 1; goto getnum;
|
||||
case CODE2:
|
||||
n = 2; goto getnum;
|
||||
case CODE4:
|
||||
n = 4; goto getnum;
|
||||
case NUMBER0:
|
||||
n = 0; c = NUMBER; goto getnum;
|
||||
case NUMBER1:
|
||||
n = 1; c = NUMBER; goto getnum;
|
||||
case NUMBER2:
|
||||
n = 2; c = NUMBER; goto getnum;
|
||||
case NUMBER3:
|
||||
n = 3; c = NUMBER; goto getnum;
|
||||
case NUMBER:
|
||||
n = 4;
|
||||
getnum:
|
||||
v = 0;
|
||||
while (--n >= 0) {
|
||||
v <<= 8;
|
||||
v |= getc(tempfile);
|
||||
}
|
||||
yylval.y_valu = v;
|
||||
return(c);
|
||||
case IDENT:
|
||||
case FBSYM:
|
||||
n = sizeof(item_t *);
|
||||
p = (char *) &yylval.y_item; break;
|
||||
#ifdef ASLD
|
||||
case MODULE:
|
||||
n = sizeof(char *);
|
||||
p = (char *) &yylval.y_strp; break;
|
||||
#endif
|
||||
case STRING:
|
||||
p = stringbuf;
|
||||
#ifdef DUK
|
||||
*p++ = n = getc(tempfile);
|
||||
p[n] = '\0';
|
||||
break;
|
||||
#else DUK
|
||||
*p++ = n = getc(tempfile); break;
|
||||
#endif DUK
|
||||
case OP_EQ:
|
||||
case OP_NE:
|
||||
case OP_LE:
|
||||
case OP_GE:
|
||||
case OP_LL:
|
||||
case OP_RR:
|
||||
case OP_OO:
|
||||
case OP_AA:
|
||||
n = 0; break;
|
||||
default:
|
||||
n = sizeof(word_t);
|
||||
p = (char *) &yylval.y_word; break;
|
||||
}
|
||||
while (--n >= 0)
|
||||
*p++ = getc(tempfile);
|
||||
return(c);
|
||||
}
|
||||
|
||||
/* ---------- lexical scan in pass 1 ---------- */
|
||||
|
||||
nextchar()
|
||||
{
|
||||
register c;
|
||||
|
||||
if (peekc != -1) {
|
||||
c = peekc;
|
||||
peekc = -1;
|
||||
return(c);
|
||||
}
|
||||
#ifdef ASLD
|
||||
if (archmode && --archsize < 0)
|
||||
return(0);
|
||||
#endif
|
||||
if ((c = getc(input)) == EOF)
|
||||
return(0);
|
||||
if (isascii(c) == 0)
|
||||
fatal("non-ascii character");
|
||||
#ifdef LISTING
|
||||
if (listflag & 0440)
|
||||
putc(c, listfile);
|
||||
#endif
|
||||
return(c);
|
||||
}
|
||||
|
||||
readcode(n)
|
||||
{
|
||||
register c;
|
||||
|
||||
yylval.y_valu = 0;
|
||||
do {
|
||||
if (
|
||||
#ifdef ASLD
|
||||
(archmode && --archsize < 0)
|
||||
||
|
||||
#endif
|
||||
(c = getc(input)) == EOF
|
||||
)
|
||||
fatal("unexpected EOF in compact input");
|
||||
yylval.y_valu <<= 8;
|
||||
yylval.y_valu |= c;
|
||||
} while (--n);
|
||||
}
|
||||
|
||||
induo(c)
|
||||
register c;
|
||||
{
|
||||
static short duo[] = {
|
||||
('='<<8) | '=', OP_EQ,
|
||||
('<'<<8) | '>', OP_NE,
|
||||
('<'<<8) | '=', OP_LE,
|
||||
('>'<<8) | '=', OP_GE,
|
||||
('<'<<8) | '<', OP_LL,
|
||||
('>'<<8) | '>', OP_RR,
|
||||
('|'<<8) | '|', OP_OO,
|
||||
('&'<<8) | '&', OP_AA,
|
||||
};
|
||||
register short *p;
|
||||
|
||||
c = (c<<8) | nextchar();
|
||||
for (p = duo; *p; p++)
|
||||
if (*p++ == c)
|
||||
return(*p++);
|
||||
peekc = c & 0377;
|
||||
return(c>>8);
|
||||
}
|
||||
|
||||
inident(c)
|
||||
char c;
|
||||
{
|
||||
register char *p;
|
||||
register item_t *ip;
|
||||
|
||||
p = readident(c);
|
||||
ip = item_search(p);
|
||||
if (ip == 0) {
|
||||
ip = item_alloc(S_UND);
|
||||
ip->i_name = remember(p);
|
||||
/* printf("ident %s %o\n", ip->i_name, ip); */
|
||||
unresolved++;
|
||||
item_insert(ip, H_LOCAL + (hashindex%H_SIZE));
|
||||
} else if (hashindex < H_SIZE) {
|
||||
assert(H_KEY == 0);
|
||||
yylval.y_word = (word_t) ip->i_valu;
|
||||
return(ip->i_type);
|
||||
}
|
||||
yylval.y_item = ip;
|
||||
return(IDENT);
|
||||
}
|
||||
|
||||
char *
|
||||
readident(c)
|
||||
register c;
|
||||
{
|
||||
static char name[NAMEMAX+1];
|
||||
register n = NAMEMAX;
|
||||
register char *p = name;
|
||||
|
||||
do {
|
||||
if (--n >= 0)
|
||||
*p++ = c;
|
||||
c = nextchar();
|
||||
} while (ISALNUM(c));
|
||||
*p++ = '\0';
|
||||
peekc = c;
|
||||
return(name);
|
||||
}
|
||||
|
||||
innumber(c)
|
||||
register c;
|
||||
{
|
||||
register char *p;
|
||||
register radix;
|
||||
static char num[20+1];
|
||||
|
||||
p = num;
|
||||
radix = 20;
|
||||
do {
|
||||
if (--radix < 0)
|
||||
fatal("number too long");
|
||||
if (isupper(c))
|
||||
c += ('a' - 'A');
|
||||
*p++ = c;
|
||||
c = nextchar();
|
||||
} while (ISALNUM(c));
|
||||
peekc = c;
|
||||
*p = '\0';
|
||||
c = *--p;
|
||||
p = num;
|
||||
radix = 10;
|
||||
if (*p == '0') {
|
||||
radix = 8;
|
||||
p++;
|
||||
if (*p == 'x') {
|
||||
radix = 16;
|
||||
p++;
|
||||
} else if (*p == 'b') {
|
||||
radix = 2;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
if (radix != 16 && (c == 'f' || c == 'b'))
|
||||
return(infbsym(num));
|
||||
yylval.y_valu = 0;
|
||||
while (c = *p++) {
|
||||
if (c > '9')
|
||||
c -= ('a' - '9' - 1);
|
||||
c -= '0';
|
||||
if (c >= radix)
|
||||
serror("digit exceeds radix");
|
||||
yylval.y_valu = yylval.y_valu * radix + c;
|
||||
}
|
||||
return(NUMBER);
|
||||
}
|
||||
|
||||
instring(termc)
|
||||
{
|
||||
register char *p;
|
||||
register c;
|
||||
|
||||
p = stringbuf+1;
|
||||
for (;;) {
|
||||
c = nextchar();
|
||||
if (c == '\n' || c == '\0') {
|
||||
peekc = c;
|
||||
serror("non-terminated string");
|
||||
break;
|
||||
}
|
||||
if (c == termc)
|
||||
break;
|
||||
if (c == '\\')
|
||||
c = inescape();
|
||||
#ifdef DUK
|
||||
if (p >= &stringbuf[STRINGMAX - 1])
|
||||
#else DUK
|
||||
if (p >= &stringbuf[STRINGMAX])
|
||||
#endif DUK
|
||||
fatal("string buffer overflow");
|
||||
*p++ = c;
|
||||
}
|
||||
stringbuf[0] = p - stringbuf - 1;
|
||||
#ifdef DUK
|
||||
*p = '\0';
|
||||
#endif DUK
|
||||
return(STRING);
|
||||
}
|
||||
|
||||
inescape()
|
||||
{
|
||||
register c, j, r;
|
||||
|
||||
c = nextchar();
|
||||
if (c >= '0' && c <= '7') {
|
||||
r = c - '0';
|
||||
for (j = 0; j < 2; j++) {
|
||||
c = nextchar();
|
||||
if (c < '0' || c > '7') {
|
||||
peekc = c;
|
||||
return(r);
|
||||
}
|
||||
r <<= 3;
|
||||
r += (c - '0');
|
||||
}
|
||||
return(r);
|
||||
}
|
||||
switch (c) {
|
||||
case 'b': return('\b');
|
||||
case 'f': return('\f');
|
||||
case 'n': return('\n');
|
||||
case 'r': return('\r');
|
||||
case 't': return('\t');
|
||||
case '\'': return('\'');
|
||||
case '"': return('"');
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
infbsym(p)
|
||||
register char *p;
|
||||
{
|
||||
register lab;
|
||||
register item_t *ip;
|
||||
|
||||
lab = *p++ - '0';
|
||||
if ((unsigned)lab < 10) {
|
||||
if (*p++ == 'f') {
|
||||
ip = fb_ptr[FB_FORW+lab];
|
||||
if (ip == 0) {
|
||||
ip = fb_alloc(lab);
|
||||
fb_ptr[FB_FORW+lab] = ip;
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
ip = fb_ptr[FB_BACK+lab];
|
||||
if (ip != 0 && *p == 0)
|
||||
goto ok;
|
||||
}
|
||||
serror("bad numeric label");
|
||||
ip = fb_alloc(0);
|
||||
ok:
|
||||
yylval.y_item = ip;
|
||||
return(FBSYM);
|
||||
}
|
||||
|
||||
hash(p)
|
||||
register char *p;
|
||||
{
|
||||
register unsigned h;
|
||||
register c;
|
||||
|
||||
h = 0;
|
||||
while (c = *p++) {
|
||||
h <<= 2;
|
||||
h += c;
|
||||
}
|
||||
return(h % H_SIZE);
|
||||
}
|
||||
|
||||
item_t *
|
||||
item_search(p)
|
||||
register char *p;
|
||||
{
|
||||
register h;
|
||||
register item_t *ip;
|
||||
|
||||
for (h = hash(p); h < H_TOTAL; h += H_SIZE) {
|
||||
ip = hashtab[h];
|
||||
while (ip != 0) {
|
||||
if (strcmp(p, ip->i_name) == 0)
|
||||
goto done;
|
||||
ip = ip->i_next;
|
||||
}
|
||||
}
|
||||
done:
|
||||
hashindex = h;
|
||||
return(ip);
|
||||
}
|
||||
|
||||
item_insert(ip, h)
|
||||
item_t *ip;
|
||||
{
|
||||
ip->i_next = hashtab[h];
|
||||
hashtab[h] = ip;
|
||||
}
|
||||
|
||||
item_t *
|
||||
item_alloc(typ)
|
||||
{
|
||||
register item_t *ip;
|
||||
static nleft = 0;
|
||||
static item_t *next;
|
||||
|
||||
if (--nleft < 0) {
|
||||
next = (item_t *) sbrk(MEMINCR);
|
||||
if ((int) next == -1)
|
||||
fatal("out of memory");
|
||||
nleft += (MEMINCR / sizeof(item_t));
|
||||
}
|
||||
ip = next++;
|
||||
ip->i_next = 0;
|
||||
ip->i_type = typ;
|
||||
ip->i_name = 0;
|
||||
ip->i_valu = 0;
|
||||
return(ip);
|
||||
}
|
||||
|
||||
item_t *
|
||||
fb_alloc(lab)
|
||||
register lab;
|
||||
{
|
||||
register item_t *ip, *p;
|
||||
|
||||
ip = item_alloc(S_UND);
|
||||
p = fb_ptr[FB_TAIL+lab];
|
||||
if (p == 0)
|
||||
fb_ptr[FB_HEAD+lab] = ip;
|
||||
else
|
||||
p->i_next = ip;
|
||||
fb_ptr[FB_TAIL+lab] = ip;
|
||||
return(ip);
|
||||
}
|
||||
|
||||
item_t *
|
||||
fb_shift(lab)
|
||||
register lab;
|
||||
{
|
||||
register item_t *ip;
|
||||
|
||||
ip = fb_ptr[FB_FORW+lab];
|
||||
if (ip == 0)
|
||||
if (pass == PASS_1)
|
||||
ip = fb_alloc(lab);
|
||||
else
|
||||
ip = fb_ptr[FB_HEAD+lab];
|
||||
fb_ptr[FB_BACK+lab] = ip;
|
||||
fb_ptr[FB_FORW+lab] = ip->i_next;
|
||||
return(ip);
|
||||
}
|
||||
@@ -1,362 +0,0 @@
|
||||
/* @(#)comm6.c 1.7 */
|
||||
/*
|
||||
* implement pseudo instructions
|
||||
*/
|
||||
|
||||
#include "comm0.h"
|
||||
#include "comm1.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
newequate(ip, typ)
|
||||
register item_t *ip;
|
||||
register short typ;
|
||||
{
|
||||
typ &= ~S_EXT;
|
||||
if (typ & S_COM)
|
||||
typ = S_UND;
|
||||
else if ((typ & S_VAR) && (typ & S_TYP) != S_ABS)
|
||||
typ = S_UND;
|
||||
#ifdef THREE_PASS
|
||||
else if (pass == PASS_1 && typ == S_UND)
|
||||
typ = S_VAR;
|
||||
else if (pass == PASS_2 && (ip->i_type & S_TYP) == S_UND)
|
||||
ip->i_type |= typ;
|
||||
#endif THREE_PASS
|
||||
if (typ == S_UND)
|
||||
serror("illegal equate");
|
||||
if (pass == PASS_3)
|
||||
assert((ip->i_type & S_TYP) == (typ & S_TYP));
|
||||
newident(ip, typ);
|
||||
}
|
||||
|
||||
newident(ip, typ)
|
||||
register item_t *ip;
|
||||
{
|
||||
register flag;
|
||||
#ifdef GENLAB
|
||||
static char genlab[] = GENLAB;
|
||||
#endif GENLAB
|
||||
|
||||
if (pass == PASS_1) {
|
||||
/* printf("declare %s: %o\n", ip->i_name, typ); */
|
||||
if (ip->i_type & ~S_EXT)
|
||||
serror("multiple declared");
|
||||
else
|
||||
--unresolved;
|
||||
ip->i_type |= typ;
|
||||
}
|
||||
if (PASS_SYMB == 0)
|
||||
return;
|
||||
#ifdef THREE_PASS
|
||||
if (ip->i_type & S_EXT)
|
||||
flag = SYM_EXT;
|
||||
else
|
||||
flag = SYM_LOC;
|
||||
#else
|
||||
flag = SYM_EXT|SYM_LOC; /* S_EXT not stable in PASS_1 */
|
||||
#endif THREE_PASS
|
||||
#ifdef GENLAB
|
||||
if (strncmp(ip->i_name, genlab, sizeof(genlab)-1) == 0)
|
||||
flag = SYM_LAB;
|
||||
#endif GENLAB
|
||||
if (sflag & flag)
|
||||
newsymb(
|
||||
ip->i_name,
|
||||
ip->i_type & (S_EXT|S_TYP),
|
||||
(short)0,
|
||||
load(ip)
|
||||
);
|
||||
}
|
||||
|
||||
newlabel(ip)
|
||||
register item_t *ip;
|
||||
{
|
||||
#ifdef THREE_PASS
|
||||
register addr_t oldval = ip->i_valu;
|
||||
#endif
|
||||
|
||||
if (DOTSCT == NULL)
|
||||
nosect();
|
||||
ip->i_type &= ~S_TYP;
|
||||
ip->i_type |= DOTTYP;
|
||||
if (store(ip, (valu_t) DOTVAL) == 0)
|
||||
return;
|
||||
#ifdef THREE_PASS
|
||||
assert(pass != PASS_2 || oldval - ip->i_valu == DOTGAIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
newsect(ip)
|
||||
register item_t *ip;
|
||||
{
|
||||
register ushort typ;
|
||||
register sect_t *sp = NULL;
|
||||
|
||||
typ = ip->i_type & S_TYP;
|
||||
if (typ == S_UND) {
|
||||
/*
|
||||
* new section
|
||||
*/
|
||||
assert(pass == PASS_1);
|
||||
--unresolved;
|
||||
typ = outhead.oh_nsect + S_MIN;
|
||||
outhead.oh_nsect++;
|
||||
if (outhead.oh_nsect > SECTMAX || typ > S_MAX)
|
||||
fatal("too many sections");
|
||||
sp = §[typ - S_MIN];
|
||||
sp->s_item = ip;
|
||||
sp->s_lign = ALIGNSECT;
|
||||
#ifdef DUK
|
||||
ip->i_type = typ;
|
||||
#else DUK
|
||||
ip->i_type = typ | S_EXT;
|
||||
#endif DUK
|
||||
ip->i_valu = 0;
|
||||
} else if (typ >= S_MIN) {
|
||||
sp = §[typ - S_MIN];
|
||||
if (sp->s_item != ip)
|
||||
sp = NULL;
|
||||
}
|
||||
if (sp == NULL)
|
||||
serror("multiple declared");
|
||||
else
|
||||
switchsect(typ);
|
||||
}
|
||||
|
||||
newbase(base)
|
||||
valu_t base;
|
||||
{
|
||||
#ifdef ASLD
|
||||
register sect_t *sp;
|
||||
|
||||
if ((sp = DOTSCT) == NULL)
|
||||
nosect();
|
||||
if (sp->s_flag & BASED)
|
||||
serror("already based");
|
||||
sp->s_base = base;
|
||||
sp->s_flag |= BASED;
|
||||
DOTVAL += base;
|
||||
#else
|
||||
warning(".base ignored");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: A rather different solution is used for ASLD and NOLD:
|
||||
* ASLD:
|
||||
* - maximum length of .comm is recorded in i_valu during PASS_1
|
||||
* - address of .comm is recorded in i_valu in later passes:
|
||||
* assigned at end of PASS_1, corrected for s_gain at end of PASS_2
|
||||
* - symbol table entries are produced in commfinish()
|
||||
* NOLD:
|
||||
* - i_valu cannot be used since it is needed for relocation info
|
||||
* - only one .comm with a particular symbol is allowed per module
|
||||
* - symbol table entries are produced in newcomm()
|
||||
*/
|
||||
newcomm(ip, val)
|
||||
register item_t *ip;
|
||||
valu_t val;
|
||||
{
|
||||
if (pass == PASS_1) {
|
||||
if (DOTSCT == NULL)
|
||||
nosect();
|
||||
if (val == 0)
|
||||
serror("bad size");
|
||||
/* printf("declare %s: %o\n", ip->i_name, DOTTYP); */
|
||||
if ((ip->i_type & ~S_EXT) == S_UND) {
|
||||
--unresolved;
|
||||
ip->i_type = S_COM|S_EXT|DOTTYP;
|
||||
#ifdef ASLD
|
||||
ip->i_valu = val;
|
||||
} else if (ip->i_type == (S_COM|S_EXT|DOTTYP)) {
|
||||
if (ip->i_valu < val)
|
||||
ip->i_valu = val;
|
||||
#endif
|
||||
} else
|
||||
serror("multiple declared");
|
||||
}
|
||||
#ifndef ASLD
|
||||
if (PASS_SYMB == 0)
|
||||
return;
|
||||
if (pass != PASS_3)
|
||||
/*
|
||||
* save symbol table index
|
||||
* for possible relocation
|
||||
*/
|
||||
ip->i_valu = outhead.oh_nname;
|
||||
#ifdef DUK
|
||||
newsymb(ip->i_name, S_COM|S_EXT|DOTTYP, (short)0, val);
|
||||
#else DUK
|
||||
newsymb(ip->i_name, S_EXT|DOTTYP, (short)0, val);
|
||||
#endif DUK
|
||||
#endif
|
||||
}
|
||||
|
||||
switchsect(newtyp)
|
||||
short newtyp;
|
||||
{
|
||||
register sect_t *sp;
|
||||
|
||||
if (sp = DOTSCT)
|
||||
sp->s_size = DOTVAL - sp->s_base;
|
||||
if (newtyp == S_UND) {
|
||||
DOTSCT = NULL;
|
||||
DOTTYP = newtyp;
|
||||
return;
|
||||
}
|
||||
assert(newtyp >= S_MIN);
|
||||
sp = §[newtyp - S_MIN];
|
||||
if (pass == PASS_3) {
|
||||
#ifdef AOUTSEEK
|
||||
aoutpart = -1;
|
||||
aoutseek[PARTEMIT] = sp->s_foff + sp->s_size - sp->s_zero;
|
||||
#else
|
||||
fseek(aoutfile[PARTEMIT], sp->s_foff + sp->s_size - sp->s_zero, 0);
|
||||
#endif
|
||||
}
|
||||
DOTVAL = sp->s_size + sp->s_base;
|
||||
DOTSCT = sp;
|
||||
DOTTYP = newtyp;
|
||||
}
|
||||
|
||||
align(bytes)
|
||||
valu_t bytes;
|
||||
{
|
||||
register valu_t gap;
|
||||
register sect_t *sp;
|
||||
|
||||
if ((sp = DOTSCT) == NULL)
|
||||
nosect();
|
||||
if (bytes == 0)
|
||||
bytes = ALIGNWORD;
|
||||
if (sp->s_lign % bytes)
|
||||
if (bytes % sp->s_lign)
|
||||
serror("illegal alignment");
|
||||
else
|
||||
sp->s_lign = bytes;
|
||||
if (pass == PASS_1)
|
||||
/*
|
||||
* be pessimistic: biggest gap possible
|
||||
*/
|
||||
gap = bytes - 1;
|
||||
else {
|
||||
/*
|
||||
* calculate gap correctly;
|
||||
* will be the same in PASS_2 and PASS_3
|
||||
*/
|
||||
if ((gap = DOTVAL % bytes) != 0)
|
||||
gap = bytes - gap;
|
||||
#ifdef THREE_PASS
|
||||
if (pass == PASS_2)
|
||||
/*
|
||||
* keep track of gain with respect to PASS_1
|
||||
*/
|
||||
DOTGAIN += (bytes - 1) - gap;
|
||||
#endif
|
||||
}
|
||||
DOTVAL += gap;
|
||||
sp->s_zero += gap;
|
||||
}
|
||||
|
||||
#ifdef RELOCATION
|
||||
newrelo(s, n)
|
||||
short s;
|
||||
{
|
||||
struct outrelo outrelo;
|
||||
#ifdef DUK
|
||||
int iscomm;
|
||||
#endif DUK
|
||||
|
||||
if (rflag == 0)
|
||||
return;
|
||||
if (PASS_RELO == 0)
|
||||
return;
|
||||
s &= ~S_DOT;
|
||||
assert((s & ~(S_COM|S_VAR|S_TYP)) == 0);
|
||||
#ifndef THREE_PASS
|
||||
if (s == S_UND)
|
||||
serror("bad relocation");
|
||||
#endif
|
||||
/*
|
||||
* always relocation info if S_VAR to solve problems with:
|
||||
* move b,d0
|
||||
* b=a
|
||||
* a: .data2 0
|
||||
*/
|
||||
#ifdef DUK
|
||||
iscomm = s & S_COM;
|
||||
#endif DUK
|
||||
s &= ~S_COM;
|
||||
if ((n & RELPC) == 0 && s == S_ABS)
|
||||
return;
|
||||
if ((n & RELPC) != 0 && s == DOTTYP)
|
||||
return;
|
||||
if (pass != PASS_3) {
|
||||
outhead.oh_nrelo++;
|
||||
return;
|
||||
}
|
||||
s &= ~S_VAR;
|
||||
outrelo.or_type = (char)n;
|
||||
outrelo.or_sect = (char)DOTTYP;
|
||||
#ifndef ASLD
|
||||
#ifdef DUK
|
||||
if (s == S_UND || iscomm) {
|
||||
#else DUK
|
||||
if (s == S_UND) {
|
||||
#endif DUK
|
||||
assert(relonami != 0);
|
||||
outrelo.or_nami = relonami-1;
|
||||
relonami = 0;
|
||||
} else
|
||||
#endif
|
||||
if (s < S_MIN) {
|
||||
assert(s == S_ABS);
|
||||
/*
|
||||
* use first non existing entry (argh)
|
||||
*/
|
||||
outrelo.or_nami = outhead.oh_nname;
|
||||
} else {
|
||||
/*
|
||||
* section symbols are at the end
|
||||
*/
|
||||
outrelo.or_nami = outhead.oh_nname
|
||||
- outhead.oh_nsect
|
||||
+ (s - S_MIN)
|
||||
;
|
||||
}
|
||||
outrelo.or_addr = (long)DOTVAL;
|
||||
putofmt((char *)&outrelo, SF_RELO, PARTRELO);
|
||||
}
|
||||
#endif
|
||||
|
||||
newsymb(name, type, desc, valu)
|
||||
register char *name;
|
||||
short type;
|
||||
short desc;
|
||||
valu_t valu;
|
||||
{
|
||||
struct outname outname;
|
||||
|
||||
if (name && *name == 0)
|
||||
name = 0;
|
||||
assert(PASS_SYMB);
|
||||
if (pass != PASS_3) {
|
||||
if (name)
|
||||
outhead.oh_nchar += strlen(name)+1;
|
||||
outhead.oh_nname++;
|
||||
return;
|
||||
}
|
||||
if (name) {
|
||||
AOUTPART(PARTCHAR);
|
||||
outname.on_foff = outhead.oh_nchar;
|
||||
do {
|
||||
AOUTPUTC(*name, PARTCHAR);
|
||||
outhead.oh_nchar++;
|
||||
} while (*name++);
|
||||
} else
|
||||
outname.on_foff = 0;
|
||||
outname.on_type = type;
|
||||
outname.on_desc = desc;
|
||||
outname.on_valu = valu & ~((0xFFFFFFFF)<<(8*sizeof(valu_t)));
|
||||
putofmt((char *)&outname, SF_NAME, PARTNAME);
|
||||
}
|
||||
@@ -1,430 +0,0 @@
|
||||
/* @(#)comm7.c 1.10 */
|
||||
/*
|
||||
* miscellaneous
|
||||
*/
|
||||
|
||||
#include "comm0.h"
|
||||
#include "comm1.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
valu_t
|
||||
load(ip)
|
||||
register item_t *ip;
|
||||
{
|
||||
#ifdef ASLD
|
||||
register short typ;
|
||||
|
||||
typ = ip->i_type & S_TYP;
|
||||
if ((typ -= S_MIN) < 0) /* S_UND or S_ABS */
|
||||
return(ip->i_valu);
|
||||
return(ip->i_valu + sect[typ].s_base);
|
||||
#else
|
||||
#ifdef DUK
|
||||
if ((ip->i_type & S_TYP) == S_UND || (ip->i_type & S_COM)) {
|
||||
#else DUK
|
||||
if ((ip->i_type & S_TYP) == S_UND) {
|
||||
#endif DUK
|
||||
if (pass == PASS_3) {
|
||||
if (relonami != 0)
|
||||
serror("relocation error");
|
||||
relonami = ip->i_valu+1;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
return(ip->i_valu);
|
||||
#endif
|
||||
}
|
||||
|
||||
store(ip, val)
|
||||
register item_t *ip;
|
||||
valu_t val;
|
||||
{
|
||||
#ifdef ASLD
|
||||
register short typ;
|
||||
|
||||
typ = ip->i_type & S_TYP;
|
||||
if ((typ -= S_MIN) >= 0)
|
||||
val -= sect[typ].s_base;
|
||||
#else
|
||||
if ((ip->i_type & S_TYP) == S_UND)
|
||||
return(0);
|
||||
#endif
|
||||
assert(pass != PASS_3 || (ip->i_type & S_VAR) || ip->i_valu == val);
|
||||
ip->i_valu = val;
|
||||
return(1);
|
||||
}
|
||||
|
||||
char *
|
||||
remember(s)
|
||||
register char *s;
|
||||
{
|
||||
register char *p;
|
||||
register n;
|
||||
static nleft = 0;
|
||||
static char *next;
|
||||
|
||||
p = s;
|
||||
n = 0;
|
||||
do
|
||||
n++;
|
||||
while (*p++);
|
||||
if ((nleft -= n) < 0) {
|
||||
next = sbrk(MEMINCR);
|
||||
if ((int) next == -1)
|
||||
fatal("out of memory");
|
||||
nleft = (MEMINCR / sizeof(char)) - n;
|
||||
assert(nleft >= 0);
|
||||
}
|
||||
p = next;
|
||||
while (*p++ = *s++)
|
||||
;
|
||||
s = next;
|
||||
next = p;
|
||||
return(s);
|
||||
}
|
||||
|
||||
combine(typ1, typ2, op)
|
||||
register typ1, typ2;
|
||||
{
|
||||
switch (op) {
|
||||
case '+':
|
||||
if (typ1 == S_ABS)
|
||||
return(typ2);
|
||||
if (typ2 == S_ABS)
|
||||
return(typ1);
|
||||
break;
|
||||
case '-':
|
||||
if (typ2 == S_ABS)
|
||||
return(typ1);
|
||||
if ((typ1 & ~S_DOT) == (typ2 & ~S_DOT) && typ1 != S_UND)
|
||||
return(S_ABS|S_VAR);
|
||||
break;
|
||||
case '>':
|
||||
if (typ1 == S_ABS && typ2 == S_ABS)
|
||||
return(S_ABS);
|
||||
if (
|
||||
((typ1 & ~S_DOT) == (typ2 & ~S_DOT) && typ1 != S_UND)
|
||||
|| (typ1 == S_ABS)
|
||||
|| (typ2 == S_ABS)
|
||||
)
|
||||
return(S_ABS|S_VAR);
|
||||
break;
|
||||
default:
|
||||
if (typ1 == S_ABS && typ2 == S_ABS)
|
||||
return(S_ABS);
|
||||
break;
|
||||
}
|
||||
if (pass != PASS_1)
|
||||
serror("illegal operator");
|
||||
return(S_UND);
|
||||
}
|
||||
|
||||
#ifdef LISTING
|
||||
printx(ndig, val)
|
||||
valu_t val;
|
||||
{
|
||||
static char buf[8];
|
||||
register char *p;
|
||||
register c, n;
|
||||
|
||||
p = buf; n = ndig;
|
||||
do {
|
||||
*p++ = (int) val & 017;
|
||||
val >>= 4;
|
||||
} while (--n);
|
||||
do {
|
||||
c = "0123456789ABCDEF"[*--p];
|
||||
putchar(c);
|
||||
} while (p > buf);
|
||||
return(ndig);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LISTING
|
||||
listline(textline)
|
||||
{
|
||||
register c;
|
||||
|
||||
if ((listflag & 4) && (c = getc(listfile)) != '\n' && textline) {
|
||||
if (listcolm >= 24)
|
||||
printf(" \\\n\t\t\t");
|
||||
else
|
||||
do {
|
||||
putchar('\t');
|
||||
listcolm += 8;
|
||||
} while (listcolm < 24);
|
||||
do {
|
||||
assert(c != EOF);
|
||||
putchar(c);
|
||||
} while ((c = getc(listfile)) != '\n');
|
||||
}
|
||||
if (listflag & 7)
|
||||
putchar('\n');
|
||||
listeoln = 1;
|
||||
listcolm = 0;
|
||||
listflag = listtemp;
|
||||
}
|
||||
#endif LISTING
|
||||
|
||||
/* ---------- code optimization ---------- */
|
||||
|
||||
#ifdef THREE_PASS
|
||||
small(fitsmall, gain)
|
||||
{
|
||||
register bit;
|
||||
register char *p;
|
||||
|
||||
if (DOTSCT == NULL)
|
||||
nosect();
|
||||
if (bflag)
|
||||
return(0);
|
||||
if ((bit = nbits++) >= BITMAX) {
|
||||
if (bit != BITMAX)
|
||||
nbits--; /* prevent wraparound */
|
||||
else if (pass == PASS_1)
|
||||
warning("bit table overflow");
|
||||
return(0);
|
||||
}
|
||||
p = &bittab[bit>>3];
|
||||
bit = 1 << (bit&7);
|
||||
switch (pass) {
|
||||
case PASS_1:
|
||||
return(0);
|
||||
case PASS_2:
|
||||
if (fitsmall) {
|
||||
DOTGAIN += gain;
|
||||
*p |= bit;
|
||||
}
|
||||
return(fitsmall);
|
||||
case PASS_3:
|
||||
assert(fitsmall || (*p & bit) == 0);
|
||||
return(*p & bit);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ---------- output ---------- */
|
||||
|
||||
emit1(arg)
|
||||
char arg;
|
||||
{
|
||||
#ifdef LISTING
|
||||
if (listeoln) {
|
||||
if (listflag & 1) {
|
||||
listcolm += printx(VALWIDTH, DOTVAL);
|
||||
listcolm++;
|
||||
putchar(' ');
|
||||
}
|
||||
listeoln = 0;
|
||||
}
|
||||
if (listflag & 2)
|
||||
listcolm += printx(2, (valu_t) arg);
|
||||
#endif
|
||||
switch (pass) {
|
||||
case PASS_1:
|
||||
if (DOTSCT == NULL)
|
||||
nosect();
|
||||
/* no break */
|
||||
case PASS_2:
|
||||
DOTSCT->s_zero = 0;
|
||||
break;
|
||||
case PASS_3:
|
||||
AOUTPART(PARTEMIT);
|
||||
while (DOTSCT->s_zero) {
|
||||
AOUTPUTC(0, PARTEMIT);
|
||||
DOTSCT->s_zero--;
|
||||
}
|
||||
AOUTPUTC(arg, PARTEMIT);
|
||||
break;
|
||||
}
|
||||
DOTVAL++;
|
||||
}
|
||||
|
||||
emit2(arg)
|
||||
short arg;
|
||||
{
|
||||
#ifdef BYTES_REVERSED
|
||||
emit1((char)(arg>>8)); emit1((char)arg);
|
||||
#else
|
||||
emit1((char)arg); emit1((char)(arg>>8));
|
||||
#endif
|
||||
}
|
||||
|
||||
emit4(arg)
|
||||
long arg;
|
||||
{
|
||||
#ifdef WORDS_REVERSED
|
||||
emit2((short)(arg>>16)); emit2((short)(arg));
|
||||
#else
|
||||
emit2((short)(arg)); emit2((short)(arg>>16));
|
||||
#endif
|
||||
}
|
||||
|
||||
emitx(val, n)
|
||||
valu_t val;
|
||||
register n;
|
||||
{
|
||||
switch (n) {
|
||||
case 1:
|
||||
emit1((char)val); break;
|
||||
case 2:
|
||||
emit2((short)val); break;
|
||||
case 4:
|
||||
emit4((long)val); break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
emitstr(zero)
|
||||
{
|
||||
register i;
|
||||
register char *p;
|
||||
|
||||
p = stringbuf;
|
||||
i = *p++ & 0377;
|
||||
while (--i >= 0)
|
||||
emit1(*p++);
|
||||
if (zero)
|
||||
emit1(0);
|
||||
}
|
||||
|
||||
/* ---------- Error checked file I/O ---------- */
|
||||
|
||||
ffreopen(s, f)
|
||||
char *s;
|
||||
FILE *f;
|
||||
{
|
||||
if (freopen(s, "r", f) == NULL)
|
||||
fatal("can't reopen %s", s);
|
||||
}
|
||||
|
||||
FILE *
|
||||
ffcreat(s)
|
||||
char *s;
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
if ((f = fopen(s, "w")) == NULL)
|
||||
fatal("can't create %s", s);
|
||||
return(f);
|
||||
}
|
||||
|
||||
FILE *
|
||||
fftemp(path, tail)
|
||||
char *path;
|
||||
{
|
||||
register char *dir;
|
||||
|
||||
if ((dir = getenv("TMPDIR")) == NULL)
|
||||
#ifdef TMPDIR
|
||||
dir = TMPDIR;
|
||||
#else
|
||||
dir = "/tmp";
|
||||
#endif
|
||||
sprintf(path, "%s/%s", dir, tail);
|
||||
return(ffcreat(mktemp(path)));
|
||||
}
|
||||
|
||||
putofmt(p, s, part)
|
||||
register char *p;
|
||||
register char *s;
|
||||
{
|
||||
register i;
|
||||
register long l;
|
||||
|
||||
AOUTPART(part);
|
||||
while (i = *s++) {
|
||||
switch (i -= '0') {
|
||||
/* case 0: p++; break; */
|
||||
case 1:
|
||||
l = (long) *((char *)p); p += sizeof(char );
|
||||
break;
|
||||
case 2:
|
||||
l = (long) *((short *)p); p += sizeof(short);
|
||||
break;
|
||||
case 4:
|
||||
l = (long) *((long *)p); p += sizeof(long );
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
while (--i >= 0) {
|
||||
AOUTPUTC((int)l, part);
|
||||
l >>= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Error handling ---------- */
|
||||
|
||||
yyerror(){} /* we will do our own error printing */
|
||||
|
||||
nosect()
|
||||
{
|
||||
fatal("no sections");
|
||||
}
|
||||
|
||||
werror()
|
||||
{
|
||||
fatal("write error");
|
||||
}
|
||||
|
||||
/* VARARGS1 */
|
||||
fatal(s, a1, a2, a3, a4)
|
||||
char *s;
|
||||
{
|
||||
nerrors++;
|
||||
diag(" (fatal)\n", s, a1, a2, a3, a4);
|
||||
stop();
|
||||
}
|
||||
|
||||
#if DEBUG == 2
|
||||
assert2(file, line)
|
||||
char *file;
|
||||
{
|
||||
fatal("assertion failed (%s, %d)", file, line);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DEBUG == 1
|
||||
assert1()
|
||||
{
|
||||
diag(" (fatal)\n", "assertion failed");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* VARARGS1 */
|
||||
serror(s, a1, a2, a3, a4)
|
||||
char *s;
|
||||
{
|
||||
nerrors++;
|
||||
diag("\n", s, a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
/* VARARGS1 */
|
||||
warning(s, a1, a2, a3, a4)
|
||||
char *s;
|
||||
{
|
||||
diag(" (warning)\n", s, a1, a2, a3, a4);
|
||||
}
|
||||
|
||||
/* VARARGS1 */
|
||||
diag(tail, s, a1, a2, a3, a4)
|
||||
char *tail, *s;
|
||||
{
|
||||
fflush(stdout);
|
||||
if (modulename)
|
||||
fprintf(stderr, "\"%s\", line %d: ", modulename, lineno);
|
||||
else
|
||||
fprintf(stderr, "%s: ", progname);
|
||||
fprintf(stderr, s, a1, a2, a3, a4);
|
||||
fprintf(stderr, tail);
|
||||
}
|
||||
|
||||
nofit()
|
||||
{
|
||||
if (pass == PASS_3)
|
||||
warning("too big");
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/* @(#)comm8.c 1.1 */
|
||||
|
||||
#include "comm0.h"
|
||||
#include "comm1.h"
|
||||
#include "y.tab.h"
|
||||
|
||||
/* ========== Machine dependent C routines ========== */
|
||||
|
||||
#include "mach5.c"
|
||||
@@ -116,6 +116,10 @@ fixregvars(saveall) {
|
||||
}
|
||||
}
|
||||
f_regsave();
|
||||
#ifndef TEM_BSIZE
|
||||
for(rv=rvlist;rv!=0;rv=rv->rv_next)
|
||||
if (rv->rv_off >= 0) rv->rv_off += TEM_BSIZE;
|
||||
#endif
|
||||
}
|
||||
|
||||
isregvar(off) long off; {
|
||||
|
||||
@@ -20,7 +20,14 @@ typedef char * string;
|
||||
#define full int
|
||||
#endif
|
||||
|
||||
#if TEM_WSIZE>2
|
||||
#define word long
|
||||
#ifndef WRD_FMT
|
||||
#define WRD_FMT "%ld"
|
||||
#define WRD_FMT "%D"
|
||||
#endif WRD_FMT
|
||||
#else
|
||||
#define word int
|
||||
#ifndef WRD_FMT
|
||||
#define WRD_FMT "%d"
|
||||
#endif WRD_FMT
|
||||
#endif
|
||||
|
||||
@@ -392,14 +392,14 @@ if(Debug>1) fprintf(stderr,"Next tuple %d,%d,%d,%d\n",
|
||||
ntup = tup->p_next;
|
||||
for (i=0,t=0;i<nregneeded && t<mincost; i++)
|
||||
t += docoerc(regtp[i],regcp[i],ply,FALSE,tup->p_rar[i]);
|
||||
if ( t<mincost && tokpatlen<=stackheight ) {
|
||||
if (t<mincost) {
|
||||
#ifndef NDEBUG
|
||||
if (Debug>2)
|
||||
fprintf(stderr,"Continuing match after coercions\n");
|
||||
#endif
|
||||
t += codegen(codep,ply,FALSE,mincost-t,0);
|
||||
}
|
||||
if ( t<mincost && tokpatlen<=stackheight ) {
|
||||
if (t<mincost) {
|
||||
mincost = t;
|
||||
besttup = tup;
|
||||
} else
|
||||
@@ -480,7 +480,6 @@ normalfailed: if (stackpad!=tokpatlen) {
|
||||
result=compute(&enodes[nodeno]);
|
||||
if (result.e_typ!=EV_REG)
|
||||
break;
|
||||
if ( in_stack(result.e_v.e_reg) ) BROKE() ; /* Check aside-stack */
|
||||
for (tp= &fakestack[stackheight-tokpatlen-1];tp>=&fakestack[0];tp--)
|
||||
if (tp->t_token==-1) {
|
||||
if(tp->t_att[0].ar==result.e_v.e_reg)
|
||||
|
||||
@@ -96,9 +96,7 @@ move(tp1,tp2,ply,toplevel,maxcost) token_p tp1,tp2; unsigned maxcost; {
|
||||
fakestack[stackheight] = *tp2;
|
||||
fakestack[stackheight+1] = *tp1;
|
||||
stackheight += 2;
|
||||
tokpatlen += 2;
|
||||
t = codegen(&coderules[mp->m_cindex],ply,toplevel,maxcost,0);
|
||||
tokpatlen -= 2;
|
||||
stackheight -= 2;
|
||||
return(t);
|
||||
}
|
||||
@@ -145,9 +143,7 @@ test(tp,ply,toplevel,maxcost) token_p tp; unsigned maxcost; {
|
||||
|
||||
fakestack[stackheight] = *tp;
|
||||
stackheight++;
|
||||
tokpatlen++;
|
||||
t = codegen(&coderules[mp->t_cindex],ply,toplevel,maxcost,0);
|
||||
tokpatlen--;
|
||||
stackheight--;
|
||||
return(t);
|
||||
}
|
||||
|
||||
@@ -392,66 +392,6 @@ tref(tp,amount) register token_p tp; {
|
||||
}
|
||||
|
||||
#define MAXSAVE 10
|
||||
/* A few routines to save the top of the current stack,
|
||||
restore it and check whether a certain register is present in the
|
||||
saved stack
|
||||
*/
|
||||
token_t aside[MAXSAVE] ;
|
||||
int aside_length = -1 ;
|
||||
|
||||
save_stack(tp) register token_p tp ; {
|
||||
int i ;
|
||||
|
||||
aside_length = &fakestack[stackheight-1] -tp;
|
||||
assert(aside_length<=MAXSAVE);
|
||||
#ifndef NDEBUG
|
||||
if (aside_length!=0 && Debug>1)
|
||||
fprintf(stderr,"Saving %d items from fakestack\n",aside_length);
|
||||
#endif
|
||||
for (i=1;i<=aside_length;i++)
|
||||
aside[i-1] = tp[i];
|
||||
stackheight -= aside_length;
|
||||
}
|
||||
|
||||
in_stack(reg) {
|
||||
register token_p tp ;
|
||||
register i ;
|
||||
register tkdef_p tdp ;
|
||||
|
||||
for ( i=0, tp=aside ; i<aside_length ; i++, tp++ )
|
||||
if (tp->t_token==-1) {
|
||||
if(tp->t_att[0].ar==reg)
|
||||
goto gotone ;
|
||||
} else {
|
||||
tdp = &tokens[tp->t_token];
|
||||
for(i=0;i<TOKENSIZE;i++)
|
||||
if (tdp->t_type[i]==EV_REG &&
|
||||
tp->t_att[i].ar==reg)
|
||||
goto gotone ;
|
||||
}
|
||||
return 0 ;
|
||||
gotone:
|
||||
#ifndef NDEBUG
|
||||
if ( Debug>2 )
|
||||
fprintf(stderr,"Register %d present on non-visible stack\n",
|
||||
reg ) ;
|
||||
#endif
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
rest_stack() {
|
||||
register int i ;
|
||||
|
||||
assert(aside_length!= -1);
|
||||
#ifndef NDEBUG
|
||||
if (aside_length!=0 && Debug>1)
|
||||
fprintf(stderr,"Restoring %d items to fakestack(%d)\n",
|
||||
aside_length,stackheight);
|
||||
#endif
|
||||
for (i=0;i<aside_length;i++)
|
||||
fakestack[stackheight++] = aside[i];
|
||||
aside_length= -1 ;
|
||||
}
|
||||
|
||||
#ifdef MAXSPLIT
|
||||
split(tp,ip,ply,toplevel) token_p tp; register int *ip; {
|
||||
@@ -478,26 +418,49 @@ split(tp,ip,ply,toplevel) token_p tp; register int *ip; {
|
||||
return(0);
|
||||
found:
|
||||
assert(stackheight+cp->c2_nsplit-1<MAXFSTACK);
|
||||
save_stack(tp);
|
||||
stp = &fakestack[stackheight-1];
|
||||
diff = stp - tp;
|
||||
assert(diff<=MAXSAVE);
|
||||
for (i=1;i<=diff;i++)
|
||||
savestack[i-1] = tp[i]; /* save top of stack */
|
||||
stackheight -= diff;
|
||||
tpl = tokpatlen;
|
||||
tokpatlen = 1;
|
||||
codegen(&coderules[cp->c2_codep],ply,toplevel,MAXINT,0);
|
||||
tokpatlen = tpl;
|
||||
rest_stack();
|
||||
for (i=0;i<diff;i++) /* restore top of stack */
|
||||
fakestack[stackheight++] = savestack[i];
|
||||
return(cp->c2_nsplit);
|
||||
}
|
||||
#endif MAXSPLIT
|
||||
|
||||
unsigned docoerc(tp,cp,ply,toplevel,forced) token_p tp; register c3_p cp; {
|
||||
token_t savestack[MAXSAVE];
|
||||
token_p stp;
|
||||
register int i,diff;
|
||||
unsigned cost;
|
||||
int tpl; /* saved tokpatlen */
|
||||
|
||||
save_stack(tp) ;
|
||||
stp = &fakestack[stackheight-1];
|
||||
diff = stp -tp;
|
||||
assert(diff<=MAXSAVE);
|
||||
#ifndef NDEBUG
|
||||
if (diff!=0 && Debug>1)
|
||||
fprintf(stderr,"Saving %d items from fakestack\n",diff);
|
||||
#endif
|
||||
for (i=1;i<=diff;i++)
|
||||
savestack[i-1] = tp[i];
|
||||
stackheight -= diff;
|
||||
tpl = tokpatlen;
|
||||
tokpatlen = 1;
|
||||
cost = codegen(&coderules[cp->c3_codep],ply,toplevel,MAXINT,forced);
|
||||
tokpatlen = tpl;
|
||||
rest_stack() ;
|
||||
#ifndef NDEBUG
|
||||
if (diff!=0 && Debug>1)
|
||||
fprintf(stderr,"Restoring %d items to fakestack(%d)\n",diff,stackheight);
|
||||
#endif
|
||||
for (i=0;i<diff;i++)
|
||||
fakestack[stackheight++] = savestack[i];
|
||||
nallreg = 0;
|
||||
return(cost);
|
||||
}
|
||||
|
||||
@@ -20,4 +20,8 @@ typedef char * string;
|
||||
#define full int
|
||||
#endif
|
||||
|
||||
#if TEM_WSIZE>2
|
||||
#define word long
|
||||
#else
|
||||
#define word int
|
||||
#endif
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
@@ -1,28 +0,0 @@
|
||||
.define putchr
|
||||
! output routine in monitor
|
||||
CRT = 0x013B
|
||||
! output a charcter
|
||||
! entry: ascii character in a
|
||||
putchr:
|
||||
push hl
|
||||
push bc
|
||||
ld hl,tab
|
||||
ld b,5
|
||||
1: cp (hl)
|
||||
jr z,fetch
|
||||
inc hl
|
||||
inc hl
|
||||
djnz 1b
|
||||
2: call CRT
|
||||
pop bc
|
||||
pop hl
|
||||
ret
|
||||
fetch: inc hl
|
||||
ld a,(hl)
|
||||
jr 2b
|
||||
! conversion table for nascom characters
|
||||
tab: .byte 0x0D,0x00
|
||||
.byte 0x1B,0x1E
|
||||
.byte 0x08,0x1D
|
||||
.byte 0x0A,0x1F
|
||||
.byte 0x7F,0x00
|
||||
@@ -1,21 +0,0 @@
|
||||
.define putchr
|
||||
|
||||
putchr:
|
||||
push hl
|
||||
push de
|
||||
push bc
|
||||
cp 0x0A
|
||||
jr nz,1f
|
||||
ld a,0x1F
|
||||
1:
|
||||
ld c,a
|
||||
2:
|
||||
in a,0xF1
|
||||
and 4
|
||||
jr z,2b
|
||||
ld a,c
|
||||
out 0xF0,a
|
||||
pop bc
|
||||
pop de
|
||||
pop hl
|
||||
ret
|
||||
@@ -1,197 +0,0 @@
|
||||
.define _read,_write,_ioctl,_getpid,_open,_close,_exit,_errno
|
||||
_read:
|
||||
ld (savebc),bc
|
||||
push af
|
||||
pop bc
|
||||
ld (saveaf),bc ! save all registers in savereg
|
||||
ld (savede),de
|
||||
ld (savehl),hl
|
||||
ld (saveix),ix
|
||||
ex (sp),hl ! return address in hl
|
||||
pop bc ! skip return address
|
||||
pop bc ! get fd
|
||||
ld a,b ! check fd = 0
|
||||
or c
|
||||
jr nz,errrd
|
||||
pop de ! get buffer
|
||||
pop bc ! get count
|
||||
ld ix,0 ! reset counter
|
||||
push bc
|
||||
push de
|
||||
push ix
|
||||
push hl ! return address
|
||||
ex de,hl ! buffer to hl
|
||||
1: ld a,b
|
||||
or c
|
||||
jr z,done ! done if count = 0
|
||||
call getchr
|
||||
ld (hl),a
|
||||
inc hl ! increment pointer
|
||||
inc ix ! increment char counter
|
||||
dec bc ! decrement count
|
||||
cp 0xA
|
||||
jr nz,1b ! done if char = CR
|
||||
done:
|
||||
ld bc,(saveaf)
|
||||
push bc
|
||||
pop af
|
||||
ld bc,(savebc)
|
||||
ld de,(savede)
|
||||
ld hl,(savehl)
|
||||
ld ix,(saveix)
|
||||
ret
|
||||
errrd:
|
||||
push bc
|
||||
push hl ! return address
|
||||
ld bc,(saveaf)
|
||||
push bc
|
||||
pop af
|
||||
ld bc,(savebc)
|
||||
ld de,(savede)
|
||||
ld hl,(savehl)
|
||||
ld ix,(saveix)
|
||||
ld ix,-1
|
||||
ret
|
||||
|
||||
_write:
|
||||
ld (savebc),bc
|
||||
push af
|
||||
pop bc
|
||||
ld (saveaf),bc ! save all registers in savereg
|
||||
ld (savede),de
|
||||
ld (savehl),hl
|
||||
ld (saveix),ix
|
||||
ex (sp),hl ! return address in hl
|
||||
pop de ! skip return address
|
||||
pop de ! get fd
|
||||
ld a,e ! check for fd = 1
|
||||
cp 1
|
||||
jr nz,errwr
|
||||
ld a,d
|
||||
or a
|
||||
jr nz,errwr
|
||||
pop de ! buffer in de
|
||||
pop bc ! count in bc
|
||||
push bc
|
||||
push de
|
||||
push de
|
||||
push hl
|
||||
ex de,hl ! buffer in hl
|
||||
ld e,c
|
||||
ld d,b ! count also in de
|
||||
1: ld a,b
|
||||
or c
|
||||
jr z,exit
|
||||
ld a,(hl)
|
||||
call putchr
|
||||
inc hl
|
||||
dec bc
|
||||
jr 1b
|
||||
errwr:
|
||||
push de
|
||||
push hl
|
||||
ld bc,(saveaf)
|
||||
push bc
|
||||
pop af
|
||||
ld bc,(savebc)
|
||||
ld de,(savede)
|
||||
ld hl,(savehl)
|
||||
ld ix,(saveix)
|
||||
ld ix,-1 ! error in fd
|
||||
ret
|
||||
exit:
|
||||
push de ! count on stack
|
||||
ld bc,(saveaf)
|
||||
push bc
|
||||
pop af
|
||||
ld bc,(savebc)
|
||||
ld de,(savede)
|
||||
ld hl,(savehl)
|
||||
ld ix,(saveix)
|
||||
pop ix ! return count to caller
|
||||
ret
|
||||
|
||||
_ioctl:
|
||||
ret
|
||||
_getpid:
|
||||
ret
|
||||
|
||||
! open return a file descriptor (0,1,2)
|
||||
! depending on 'mode'
|
||||
! mode 2 doesn't work!!
|
||||
_open:
|
||||
ld (savebc),bc
|
||||
push af
|
||||
pop bc
|
||||
ld (saveaf),bc ! save all registers in savereg
|
||||
ld (savede),de
|
||||
ld (savehl),hl
|
||||
ld (saveix),ix
|
||||
pop bc ! return address
|
||||
pop de ! name pointer
|
||||
pop ix ! mode (0 for read,
|
||||
! 1 for write)
|
||||
push ix
|
||||
push de
|
||||
push bc
|
||||
ld bc,(saveaf)
|
||||
push bc
|
||||
pop af
|
||||
ld bc,(savebc)
|
||||
ld de,(savede)
|
||||
ld hl,(savehl)
|
||||
ld ix,(saveix)
|
||||
ret ! return fd = 0 for read
|
||||
! fd = 1 for write
|
||||
|
||||
_close:
|
||||
ld ix,0 ! return succes
|
||||
ret
|
||||
_exit:
|
||||
jp 0x38
|
||||
.data
|
||||
_errno:
|
||||
.word 0
|
||||
! output routine in monitor
|
||||
CRT = 0x013B
|
||||
! output a charcter
|
||||
! entry: ascii character in a
|
||||
.text
|
||||
!putchr:
|
||||
! push hl
|
||||
! push bc
|
||||
! ld hl,tab
|
||||
! ld b,5
|
||||
!1: cp (hl)
|
||||
! jr z,fetch
|
||||
! inc hl
|
||||
! inc hl
|
||||
! djnz 1b
|
||||
!2: call CRT
|
||||
! pop bc
|
||||
! pop hl
|
||||
! ret
|
||||
!fetch: inc hl
|
||||
! ld a,(hl)
|
||||
! jr 2b
|
||||
!! conversion table for nascom characters
|
||||
!tab: .byte 0x0D,0x00
|
||||
! .byte 0x1B,0x1E
|
||||
! .byte 0x08,0x1D
|
||||
! .byte 0x0A,0x1F
|
||||
! .byte 0x7F,0x00
|
||||
|
||||
KBD = 0x69
|
||||
! get character from keyboard
|
||||
getchr:
|
||||
call KBD
|
||||
jr nc,getchr
|
||||
cp 0x1F
|
||||
jr z,CR
|
||||
cp 0x1D
|
||||
jr z,BS
|
||||
ret
|
||||
CR: ld a,0xA
|
||||
ret
|
||||
BS: ld a,0x8
|
||||
ret
|
||||
@@ -1,28 +0,0 @@
|
||||
.define putchr
|
||||
! output routine in monitor
|
||||
CRT = 0x013B
|
||||
! output a charcter
|
||||
! entry: ascii character in a
|
||||
putchr:
|
||||
push hl
|
||||
push bc
|
||||
ld hl,tab
|
||||
ld b,5
|
||||
1: cp (hl)
|
||||
jr z,fetch
|
||||
inc hl
|
||||
inc hl
|
||||
djnz 1b
|
||||
2: call CRT
|
||||
pop bc
|
||||
pop hl
|
||||
ret
|
||||
fetch: inc hl
|
||||
ld a,(hl)
|
||||
jr 2b
|
||||
! conversion table for nascom characters
|
||||
tab: .byte 0x0D,0x00
|
||||
.byte 0x1B,0x1E
|
||||
.byte 0x08,0x1D
|
||||
.byte 0x0A,0x1F
|
||||
.byte 0x7F,0x00
|
||||
@@ -1,21 +0,0 @@
|
||||
.define putchr
|
||||
|
||||
putchr:
|
||||
push hl
|
||||
push de
|
||||
push bc
|
||||
cp 0x0A
|
||||
jr nz,1f
|
||||
ld a,0x1F
|
||||
1:
|
||||
ld c,a
|
||||
2:
|
||||
in a,0xF1
|
||||
and 4
|
||||
jr z,2b
|
||||
ld a,c
|
||||
out 0xF0,a
|
||||
pop bc
|
||||
pop de
|
||||
pop hl
|
||||
ret
|
||||
@@ -1,197 +0,0 @@
|
||||
.define _read,_write,_ioctl,_getpid,_open,_close,_exit,_errno
|
||||
_read:
|
||||
ld (savebc),bc
|
||||
push af
|
||||
pop bc
|
||||
ld (saveaf),bc ! save all registers in savereg
|
||||
ld (savede),de
|
||||
ld (savehl),hl
|
||||
ld (saveix),ix
|
||||
ex (sp),hl ! return address in hl
|
||||
pop bc ! skip return address
|
||||
pop bc ! get fd
|
||||
ld a,b ! check fd = 0
|
||||
or c
|
||||
jr nz,errrd
|
||||
pop de ! get buffer
|
||||
pop bc ! get count
|
||||
ld ix,0 ! reset counter
|
||||
push bc
|
||||
push de
|
||||
push ix
|
||||
push hl ! return address
|
||||
ex de,hl ! buffer to hl
|
||||
1: ld a,b
|
||||
or c
|
||||
jr z,done ! done if count = 0
|
||||
call getchr
|
||||
ld (hl),a
|
||||
inc hl ! increment pointer
|
||||
inc ix ! increment char counter
|
||||
dec bc ! decrement count
|
||||
cp 0xA
|
||||
jr nz,1b ! done if char = CR
|
||||
done:
|
||||
ld bc,(saveaf)
|
||||
push bc
|
||||
pop af
|
||||
ld bc,(savebc)
|
||||
ld de,(savede)
|
||||
ld hl,(savehl)
|
||||
ld ix,(saveix)
|
||||
ret
|
||||
errrd:
|
||||
push bc
|
||||
push hl ! return address
|
||||
ld bc,(saveaf)
|
||||
push bc
|
||||
pop af
|
||||
ld bc,(savebc)
|
||||
ld de,(savede)
|
||||
ld hl,(savehl)
|
||||
ld ix,(saveix)
|
||||
ld ix,-1
|
||||
ret
|
||||
|
||||
_write:
|
||||
ld (savebc),bc
|
||||
push af
|
||||
pop bc
|
||||
ld (saveaf),bc ! save all registers in savereg
|
||||
ld (savede),de
|
||||
ld (savehl),hl
|
||||
ld (saveix),ix
|
||||
ex (sp),hl ! return address in hl
|
||||
pop de ! skip return address
|
||||
pop de ! get fd
|
||||
ld a,e ! check for fd = 1
|
||||
cp 1
|
||||
jr nz,errwr
|
||||
ld a,d
|
||||
or a
|
||||
jr nz,errwr
|
||||
pop de ! buffer in de
|
||||
pop bc ! count in bc
|
||||
push bc
|
||||
push de
|
||||
push de
|
||||
push hl
|
||||
ex de,hl ! buffer in hl
|
||||
ld e,c
|
||||
ld d,b ! count also in de
|
||||
1: ld a,b
|
||||
or c
|
||||
jr z,exit
|
||||
ld a,(hl)
|
||||
call putchr
|
||||
inc hl
|
||||
dec bc
|
||||
jr 1b
|
||||
errwr:
|
||||
push de
|
||||
push hl
|
||||
ld bc,(saveaf)
|
||||
push bc
|
||||
pop af
|
||||
ld bc,(savebc)
|
||||
ld de,(savede)
|
||||
ld hl,(savehl)
|
||||
ld ix,(saveix)
|
||||
ld ix,-1 ! error in fd
|
||||
ret
|
||||
exit:
|
||||
push de ! count on stack
|
||||
ld bc,(saveaf)
|
||||
push bc
|
||||
pop af
|
||||
ld bc,(savebc)
|
||||
ld de,(savede)
|
||||
ld hl,(savehl)
|
||||
ld ix,(saveix)
|
||||
pop ix ! return count to caller
|
||||
ret
|
||||
|
||||
_ioctl:
|
||||
ret
|
||||
_getpid:
|
||||
ret
|
||||
|
||||
! open return a file descriptor (0,1,2)
|
||||
! depending on 'mode'
|
||||
! mode 2 doesn't work!!
|
||||
_open:
|
||||
ld (savebc),bc
|
||||
push af
|
||||
pop bc
|
||||
ld (saveaf),bc ! save all registers in savereg
|
||||
ld (savede),de
|
||||
ld (savehl),hl
|
||||
ld (saveix),ix
|
||||
pop bc ! return address
|
||||
pop de ! name pointer
|
||||
pop ix ! mode (0 for read,
|
||||
! 1 for write)
|
||||
push ix
|
||||
push de
|
||||
push bc
|
||||
ld bc,(saveaf)
|
||||
push bc
|
||||
pop af
|
||||
ld bc,(savebc)
|
||||
ld de,(savede)
|
||||
ld hl,(savehl)
|
||||
ld ix,(saveix)
|
||||
ret ! return fd = 0 for read
|
||||
! fd = 1 for write
|
||||
|
||||
_close:
|
||||
ld ix,0 ! return succes
|
||||
ret
|
||||
_exit:
|
||||
jp 0x38
|
||||
.data
|
||||
_errno:
|
||||
.word 0
|
||||
! output routine in monitor
|
||||
CRT = 0x013B
|
||||
! output a charcter
|
||||
! entry: ascii character in a
|
||||
.text
|
||||
!putchr:
|
||||
! push hl
|
||||
! push bc
|
||||
! ld hl,tab
|
||||
! ld b,5
|
||||
!1: cp (hl)
|
||||
! jr z,fetch
|
||||
! inc hl
|
||||
! inc hl
|
||||
! djnz 1b
|
||||
!2: call CRT
|
||||
! pop bc
|
||||
! pop hl
|
||||
! ret
|
||||
!fetch: inc hl
|
||||
! ld a,(hl)
|
||||
! jr 2b
|
||||
!! conversion table for nascom characters
|
||||
!tab: .byte 0x0D,0x00
|
||||
! .byte 0x1B,0x1E
|
||||
! .byte 0x08,0x1D
|
||||
! .byte 0x0A,0x1F
|
||||
! .byte 0x7F,0x00
|
||||
|
||||
KBD = 0x69
|
||||
! get character from keyboard
|
||||
getchr:
|
||||
call KBD
|
||||
jr nc,getchr
|
||||
cp 0x1F
|
||||
jr z,CR
|
||||
cp 0x1D
|
||||
jr z,BS
|
||||
ret
|
||||
CR: ld a,0xA
|
||||
ret
|
||||
BS: ld a,0x8
|
||||
ret
|
||||
@@ -1,53 +0,0 @@
|
||||
# $Header$
|
||||
EM = ../../..
|
||||
h = $(EM)/h
|
||||
CDIR = $(EM)/mach/proto/nas
|
||||
CPP = $(EM)/lib/cpp
|
||||
DEF =
|
||||
|
||||
FFLAG =
|
||||
CFLAGS = $(FFLAG) -O -I$h $(DEF)
|
||||
YFLAGS = -d
|
||||
LDFLAGS = $(FFLAG) -i
|
||||
|
||||
CSRC = $(CDIR)/comm3.c $(CDIR)/comm4.c $(CDIR)/comm5.c \
|
||||
$(CDIR)/comm6.c $(CDIR)/comm7.c $(CDIR)/comm8.c
|
||||
COBJ = $(CDIR)/comm3.o $(CDIR)/comm4.o $(CDIR)/comm5.o \
|
||||
$(CDIR)/comm6.o $(CDIR)/comm7.o $(CDIR)/comm8.o
|
||||
MACH = mach0.c mach1.c mach2.c mach3.c mach4.c mach5.c
|
||||
COMM = $(CDIR)/comm0.h $(CDIR)/comm1.h $(CDIR)/comm2.y $(CSRC)
|
||||
|
||||
all: as
|
||||
|
||||
install:all
|
||||
../../install as
|
||||
|
||||
cmp:
|
||||
-../../compare as
|
||||
|
||||
clean:
|
||||
rm -f *.o as as.[cy] y.tab.h
|
||||
|
||||
pr: $(MACH)
|
||||
@pr -n $(MACH)
|
||||
|
||||
opr:
|
||||
make pr | opr
|
||||
as: $(COBJ) as.o
|
||||
$(CC) $(LDFLAGS) $(COBJ) as.o -o as
|
||||
|
||||
as.y: $(CDIR)/comm2.y
|
||||
$(CPP) -P -I$h $(DEF) $(CDIR)/comm2.y >as.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
|
||||
lint: $(CSRC) as.c
|
||||
lint $(CSRC) as.c
|
||||
|
||||
y.tab.h: as.c
|
||||
$(COBJ): y.tab.h
|
||||
$(COBJ) as.y: $(CDIR)/comm0.h mach0.c
|
||||
$(COBJ) as.y: $(CDIR)/comm1.h mach1.c
|
||||
as.y: mach2.c
|
||||
comm3.o: mach3.c
|
||||
as.y: mach4.c
|
||||
comm8.o: mach5.c
|
||||
Reference in New Issue
Block a user