Compare commits
426 Commits
unlabeled-
...
distr2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d7ceb6d6c | ||
|
|
d10d14acac | ||
|
|
ca5599714b | ||
|
|
f337b8df6d | ||
|
|
7cd58cabab | ||
|
|
8b4f21bd95 | ||
|
|
ab820d3083 | ||
|
|
fb23d440f0 | ||
|
|
f70b857d1b | ||
|
|
bd07643039 | ||
|
|
686e5af1bb | ||
|
|
34ccddfc2d | ||
|
|
b6f73fdc29 | ||
|
|
c19324dfea | ||
|
|
772b64fabd | ||
|
|
ef92740400 | ||
|
|
ee9c5be180 | ||
|
|
ca9a6feeb0 | ||
|
|
022cb596be | ||
|
|
9eb53c3d47 | ||
|
|
dfcfa9883b | ||
|
|
fb6d291d38 | ||
|
|
e4e29ae837 | ||
|
|
94534b7c15 | ||
|
|
491040b2c7 | ||
|
|
b4adc21f19 | ||
|
|
bae4084355 | ||
|
|
d394fe5dda | ||
|
|
dcfe4e8a97 | ||
|
|
be9e253a2f | ||
|
|
620216fb26 | ||
|
|
70d71f4355 | ||
|
|
6b87f1082e | ||
|
|
fd44c34a61 | ||
|
|
6c247029bd | ||
|
|
6bbdb92784 | ||
|
|
22182c0d7f | ||
|
|
87f66789de | ||
|
|
1879c8e724 | ||
|
|
693830b09a | ||
|
|
e3fa99632e | ||
|
|
b3d11b1fa5 | ||
|
|
2b6187a009 | ||
|
|
a8fc6009f7 | ||
|
|
92141b52ce | ||
|
|
b63f304db1 | ||
|
|
ec3e755168 | ||
|
|
a41ff68078 | ||
|
|
244e172413 | ||
|
|
da936740a6 | ||
|
|
35fae90a9d | ||
|
|
c5a739c68f | ||
|
|
dc92fe358e | ||
|
|
59996174b6 | ||
|
|
84f9364d4c | ||
|
|
a635fb0203 | ||
|
|
e3e1c5ac20 | ||
|
|
e3e9add8b1 | ||
|
|
ffd0d165a7 | ||
|
|
c1d5a0c721 | ||
|
|
3e743d78f3 | ||
|
|
90c847ca59 | ||
|
|
1b162c577e | ||
|
|
a5f4b01d82 | ||
|
|
c5508c7c0b | ||
|
|
80e349860b | ||
|
|
157b243956 | ||
|
|
eabf214312 | ||
|
|
d52117c8dd | ||
|
|
d457c50945 | ||
|
|
b294ab5042 | ||
|
|
9d0812746b | ||
|
|
9f203c9a17 | ||
|
|
0c92039ba4 | ||
|
|
cf6d084155 | ||
|
|
7e6a6f6de2 | ||
|
|
954d3a0326 | ||
|
|
6f6356e0b4 | ||
|
|
9e26d0e0c0 | ||
|
|
bf3ba84e92 | ||
|
|
7a790e48fb | ||
|
|
32bc0f2982 | ||
|
|
fb4a3fd479 | ||
|
|
ccdb8693ee | ||
|
|
a8c5699241 | ||
|
|
e0c4e4b686 | ||
|
|
8a40c25069 | ||
|
|
0fd729951a | ||
|
|
7a30dc4868 | ||
|
|
4b1965afbc | ||
|
|
b2b281f525 | ||
|
|
d2a6847715 | ||
|
|
2690f07cbd | ||
|
|
aa82964563 | ||
|
|
c636aba734 | ||
|
|
ce92663b0a | ||
|
|
a89ba7074f | ||
|
|
a71e706aa4 | ||
|
|
736a2d1022 | ||
|
|
17e13e9e71 | ||
|
|
9d7b94ba34 | ||
|
|
218f7ed718 | ||
|
|
cb0b2e08cf | ||
|
|
c2a990768d | ||
|
|
36537eccc0 | ||
|
|
6cdcb391fb | ||
|
|
9d9c9ae97b | ||
|
|
c478b62711 | ||
|
|
e7f7f33f60 | ||
|
|
c1f3dbba33 | ||
|
|
d5098fe70f | ||
|
|
469d075e77 | ||
|
|
2a4b3fd616 | ||
|
|
408dacc2aa | ||
|
|
7397122695 | ||
|
|
abcbc93b5d | ||
|
|
de6ce0fe74 | ||
|
|
b449b94b48 | ||
|
|
7d85a4c0b3 | ||
|
|
66ab97d2b0 | ||
|
|
241a7de970 | ||
|
|
41d580c9cf | ||
|
|
ec46d547c4 | ||
|
|
daa47964a5 | ||
|
|
ee63833f41 | ||
|
|
445d52de66 | ||
|
|
b82c00e153 | ||
|
|
972692cb1c | ||
|
|
bbfb511322 | ||
|
|
3f3bddef8f | ||
|
|
9f45dd0650 | ||
|
|
43a2b60360 | ||
|
|
14875e6ca5 | ||
|
|
d32de5df93 | ||
|
|
eeb944f6e3 | ||
|
|
ca28f34c8e | ||
|
|
625c309fa6 | ||
|
|
9f3928cd3a | ||
|
|
a65f05f29f | ||
|
|
6a6a84a274 | ||
|
|
4f80e81ee7 | ||
|
|
eb2b9d0bac | ||
|
|
792d315beb | ||
|
|
04e454d3c6 | ||
|
|
a1c2dadb2a | ||
|
|
b6381fad79 | ||
|
|
c9eb48d373 | ||
|
|
67d635ccd4 | ||
|
|
f37307bc06 | ||
|
|
2a4335787e | ||
|
|
1b5278f3d4 | ||
|
|
815b0e0f0f | ||
|
|
70c000b03e | ||
|
|
f59262745e | ||
|
|
cc4f8a793a | ||
|
|
52fee02e94 | ||
|
|
fee336890b | ||
|
|
0b6744bb91 | ||
|
|
e704ddc158 | ||
|
|
f7699474b8 | ||
|
|
6909adbf9c | ||
|
|
156775643e | ||
|
|
d41c902b12 | ||
|
|
43f003e959 | ||
|
|
ba1e51e914 | ||
|
|
66875f1bde | ||
|
|
8a7ee2ea50 | ||
|
|
e9850f2691 | ||
|
|
0122bc2dd7 | ||
|
|
c0085c2dd4 | ||
|
|
00d75279e7 | ||
|
|
c0d87aaa16 | ||
|
|
3c7fcfe81a | ||
|
|
4ff7e05f7e | ||
|
|
3df42a584c | ||
|
|
9c93cbdfaa | ||
|
|
1b36afae36 | ||
|
|
0ff3a17f5e | ||
|
|
d7abe0e8b6 | ||
|
|
20986fd6ea | ||
|
|
293dfd2c64 | ||
|
|
e1b8023da1 | ||
|
|
52d0f32e32 | ||
|
|
c8e426ffb8 | ||
|
|
b70b6ba980 | ||
|
|
c90c70bb84 | ||
|
|
a50f8ebe1c | ||
|
|
da898f1325 | ||
|
|
1e38fa0573 | ||
|
|
5a6676cc53 | ||
|
|
987ed39adb | ||
|
|
3d4a5efe99 | ||
|
|
46f5004866 | ||
|
|
df168727a6 | ||
|
|
2cc4735151 | ||
|
|
dd7e9436a2 | ||
|
|
8e154eb826 | ||
|
|
ca219d89e9 | ||
|
|
26999bb517 | ||
|
|
103659cd7b | ||
|
|
626ae9760f | ||
|
|
dcd8451347 | ||
|
|
882906b3c3 | ||
|
|
f586956618 | ||
|
|
6459b0bf5f | ||
|
|
1f56b2aa4c | ||
|
|
d1c0d1db13 | ||
|
|
b99ce86e16 | ||
|
|
bec394f7bd | ||
|
|
db19d06f61 | ||
|
|
e936aea1e1 | ||
|
|
31eab814f2 | ||
|
|
7f9dd27dc8 | ||
|
|
387191a2c7 | ||
|
|
cf3d3ad287 | ||
|
|
1bc30e42eb | ||
|
|
e271d9bbb8 | ||
|
|
a49f2d23f7 | ||
|
|
3c5d3c55af | ||
|
|
6d344b6702 | ||
|
|
8fa5a7b668 | ||
|
|
d12fef6c05 | ||
|
|
ed1ee8a3b4 | ||
|
|
3bb153d6bb | ||
|
|
df08133a04 | ||
|
|
06087a6bc3 | ||
|
|
fd4d46036a | ||
|
|
1e3ec09984 | ||
|
|
58c5d2d8ac | ||
|
|
410800127c | ||
|
|
1732114593 | ||
|
|
66eabbcddf | ||
|
|
468401cb81 | ||
|
|
cac6ffd8c2 | ||
|
|
d32d4e6ba0 | ||
|
|
5cad6f6aa7 | ||
|
|
e46c49e291 | ||
|
|
5a95c31414 | ||
|
|
f487f26e00 | ||
|
|
e95492dfb0 | ||
|
|
fefe15a844 | ||
|
|
3d2c33e277 | ||
|
|
2ea3be322d | ||
|
|
a849b751a9 | ||
|
|
ea337060ec | ||
|
|
33c81637db | ||
|
|
8bdec01d71 | ||
|
|
7556180ab3 | ||
|
|
09000449a4 | ||
|
|
68644410fb | ||
|
|
c2e988c3d5 | ||
|
|
d4a597912f | ||
|
|
682e5d9b8a | ||
|
|
f7027ba7e4 | ||
|
|
52a627589a | ||
|
|
5fc9fdf795 | ||
|
|
08c8edf314 | ||
|
|
603f82a578 | ||
|
|
8f81c858f8 | ||
|
|
6a21488f0c | ||
|
|
374ac8b21c | ||
|
|
770f321ea8 | ||
|
|
decda89fba | ||
|
|
ff46181ae0 | ||
|
|
dbb0d46ac2 | ||
|
|
d53ef52028 | ||
|
|
a91ff9e04b | ||
|
|
56a8cd53b6 | ||
|
|
0c2aee4835 | ||
|
|
cd78a1a27a | ||
|
|
309bbef3ea | ||
|
|
71cbd2c92f | ||
|
|
cb49888304 | ||
|
|
9479f61318 | ||
|
|
8d02182e12 | ||
|
|
aef211ad4e | ||
|
|
a33d0e8e14 | ||
|
|
4f40987ff0 | ||
|
|
ccfa0db0de | ||
|
|
6ac5841c7f | ||
|
|
f9c86fc6f6 | ||
|
|
a4ca3054f0 | ||
|
|
10ce06ff2b | ||
|
|
8d87404836 | ||
|
|
2d8dcaa2df | ||
|
|
d8d2068664 | ||
|
|
e1ef16649c | ||
|
|
6512a304a0 | ||
|
|
e75b8772ca | ||
|
|
d19105ef78 | ||
|
|
f9b105e07a | ||
|
|
218ce4596e | ||
|
|
8f7a447719 | ||
|
|
14a9b13fd3 | ||
|
|
d72ad93216 | ||
|
|
081413cfda | ||
|
|
f0d34942e3 | ||
|
|
959138af97 | ||
|
|
c61ea7ee53 | ||
|
|
22e4268cc7 | ||
|
|
e2c5191f0c | ||
|
|
7f0def8861 | ||
|
|
dac2f97109 | ||
|
|
3a528a7324 | ||
|
|
3534869cb5 | ||
|
|
e9b6045b5a | ||
|
|
a1a8fd99a0 | ||
|
|
d7fb9edfe2 | ||
|
|
58126396af | ||
|
|
55017702e2 | ||
|
|
7d312abd59 | ||
|
|
ba826bad5c | ||
|
|
4ba6e7a39c | ||
|
|
f838dd1047 | ||
|
|
6aaff51b39 | ||
|
|
f532b58045 | ||
|
|
576688fc10 | ||
|
|
72b83cca59 | ||
|
|
5edf93d2de | ||
|
|
dd0951f114 | ||
|
|
5779a88371 | ||
|
|
22c95138aa | ||
|
|
d0268a4ec1 | ||
|
|
112211eb3b | ||
|
|
d0444e3a04 | ||
|
|
9beb72e69b | ||
|
|
5fedca22ad | ||
|
|
b4ad7c46da | ||
|
|
c2229e5c60 | ||
|
|
11b3f3aa8a | ||
|
|
79411cb4b3 | ||
|
|
dd8505531b | ||
|
|
26f38cada3 | ||
|
|
c235c1a93d | ||
|
|
d16efbab98 | ||
|
|
57115f49cc | ||
|
|
5e8a571801 | ||
|
|
006c4b7a49 | ||
|
|
5662050ad3 | ||
|
|
6a08d40d15 | ||
|
|
fe6eed6c76 | ||
|
|
0ebd337637 | ||
|
|
ffb167e8b2 | ||
|
|
6860747f3e | ||
|
|
18dbfc024e | ||
|
|
e129db8343 | ||
|
|
b2b1167d7a | ||
|
|
6c9e4c84f0 | ||
|
|
6b38714690 | ||
|
|
80d385c291 | ||
|
|
37d01caabd | ||
|
|
7b39ce2cfa | ||
|
|
53a88ccd69 | ||
|
|
2d4614ca5a | ||
|
|
246f45c867 | ||
|
|
b544d3b401 | ||
|
|
5f41dcd958 | ||
|
|
9ea83d0838 | ||
|
|
45e2eea414 | ||
|
|
8b60227186 | ||
|
|
f0a6c2fbcf | ||
|
|
8636bd025e | ||
|
|
4d8c88e7b1 | ||
|
|
b4faacec8c | ||
|
|
eb15231cf4 | ||
|
|
cf947cedd3 | ||
|
|
e3bf7b5dc7 | ||
|
|
a5e9c4f8d1 | ||
|
|
8c874d4632 | ||
|
|
d267037189 | ||
|
|
ea8e311e5a | ||
|
|
3ab2889451 | ||
|
|
c693044013 | ||
|
|
3b3d3f16b4 | ||
|
|
4f071008c8 | ||
|
|
d77b2081c0 | ||
|
|
b097fe72a7 | ||
|
|
66d68121c8 | ||
|
|
5060a9fcd6 | ||
|
|
523457f6ee | ||
|
|
6babe9fccd | ||
|
|
ad815f1061 | ||
|
|
aa0f76a6cd | ||
|
|
c39e619032 | ||
|
|
4a2c2d89a0 | ||
|
|
468cdfd3eb | ||
|
|
83f3de1555 | ||
|
|
ef7ea116cd | ||
|
|
f4ab1bb6e6 | ||
|
|
98989fd9ca | ||
|
|
9932e38ab2 | ||
|
|
0b9b183085 | ||
|
|
4cc2986757 | ||
|
|
9f850cbb2d | ||
|
|
24204bca9f | ||
|
|
1e651a534a | ||
|
|
1b210a8104 | ||
|
|
a0f184e3d1 | ||
|
|
9b6c26ad14 | ||
|
|
89a757d6f9 | ||
|
|
518e817345 | ||
|
|
f9fa5df654 | ||
|
|
9e4b9fddab | ||
|
|
7f12f20be6 | ||
|
|
9019141137 | ||
|
|
af75a28622 | ||
|
|
c744b44b48 | ||
|
|
80d4c7ca2f | ||
|
|
c2d3d6ce4a | ||
|
|
47f5e79d96 | ||
|
|
2c7c97051b | ||
|
|
0d5c765070 | ||
|
|
01d4011dd6 | ||
|
|
7f3328678f | ||
|
|
d9fe7e9cf0 | ||
|
|
4e461a9860 | ||
|
|
3cdaf9f4ba | ||
|
|
0d0e2d2d22 | ||
|
|
8d659c015f | ||
|
|
695a914eb3 | ||
|
|
9b72991e27 | ||
|
|
8db2c12881 | ||
|
|
7e8d898bcb | ||
|
|
550e4d3cee | ||
|
|
271b83ecb3 | ||
|
|
ee3ef338db |
135
Action
Normal file
135
Action
Normal file
@@ -0,0 +1,135 @@
|
||||
name "System definition"
|
||||
dir first
|
||||
action did_first
|
||||
failure "You have to run the shell script first in the directory first"
|
||||
fatal
|
||||
end
|
||||
name "EM definition"
|
||||
dir etc
|
||||
end
|
||||
name "C preprocessor"
|
||||
dir util/cpp
|
||||
end
|
||||
name "EM definition library"
|
||||
dir util/data
|
||||
end
|
||||
name "Encode/Decode"
|
||||
dir util/misc
|
||||
end
|
||||
name "Shell files in bin"
|
||||
dir util/shf
|
||||
end
|
||||
name "EM assembler"
|
||||
dir util/ass
|
||||
end
|
||||
name "EM Peephole optimizer"
|
||||
dir util/opt
|
||||
end
|
||||
name "ACK archiver"
|
||||
dir util/arch
|
||||
end
|
||||
name "Program 'ack'"
|
||||
dir util/ack
|
||||
end
|
||||
name "Bootstrap for backend tables"
|
||||
dir util/cgg
|
||||
end
|
||||
name "LL(1) Parser generator"
|
||||
dir util/LLgen
|
||||
end
|
||||
name "Bootstrap for newest form of backend tables"
|
||||
dir util/ncgg
|
||||
end
|
||||
name "C frontend"
|
||||
dir lang/cem/comp
|
||||
end
|
||||
name "Basic frontend"
|
||||
dir lang/basic/src
|
||||
end
|
||||
name "Intel 8086 support"
|
||||
dir mach/i86
|
||||
indir
|
||||
end
|
||||
name "MSC6500 support"
|
||||
dir mach/6500
|
||||
indir
|
||||
end
|
||||
name "Motorola 6800 support"
|
||||
dir mach/6800
|
||||
indir
|
||||
end
|
||||
name "Motorola 6805 support"
|
||||
dir mach/6805
|
||||
indir
|
||||
end
|
||||
name "Motorola 6809 support"
|
||||
dir mach/6809
|
||||
indir
|
||||
end
|
||||
name "Intel 8080 support"
|
||||
dir mach/i80
|
||||
indir
|
||||
end
|
||||
name "2-2 Interpreter support"
|
||||
dir mach/int22
|
||||
indir
|
||||
end
|
||||
name "2-4 Interpreter support"
|
||||
dir mach/int24
|
||||
indir
|
||||
end
|
||||
name "4-4 Interpreter support"
|
||||
dir mach/int44
|
||||
indir
|
||||
end
|
||||
name "IBM PC/IX support"
|
||||
dir mach/ix
|
||||
indir
|
||||
end
|
||||
name "Motorola 68000 2-4 support"
|
||||
dir mach/m68k2
|
||||
indir
|
||||
end
|
||||
name "Motorola 68000 4-4 support"
|
||||
dir mach/m68k4
|
||||
indir
|
||||
end
|
||||
name "NS16032 support"
|
||||
dir mach/ns
|
||||
indir
|
||||
end
|
||||
name "PDP 11 support"
|
||||
dir mach/pdp
|
||||
indir
|
||||
end
|
||||
name "PMDS support"
|
||||
dir mach/pmds
|
||||
indir
|
||||
end
|
||||
name "PMDS 4/4 support"
|
||||
dir mach/pmds4
|
||||
indir
|
||||
end
|
||||
name "Signetics 2650 support"
|
||||
dir mach/s2650
|
||||
indir
|
||||
end
|
||||
name "Vax 2-4 support"
|
||||
dir mach/vax2
|
||||
indir
|
||||
end
|
||||
name "Vax 4-4 support"
|
||||
dir mach/vax4
|
||||
indir
|
||||
end
|
||||
name "Z80 support"
|
||||
dir mach/z80
|
||||
indir
|
||||
end
|
||||
name "Zilog Z8000 support"
|
||||
dir mach/z8000
|
||||
indir
|
||||
end
|
||||
name "Pascal frontend"
|
||||
dir lang/pc/pem
|
||||
end
|
||||
1
DistrAction
Executable file
1
DistrAction
Executable file
@@ -0,0 +1 @@
|
||||
exec sh TakeAction distr distr/Action
|
||||
35
Makefile
35
Makefile
@@ -1,35 +0,0 @@
|
||||
cmp: # compile everything and compare
|
||||
(cd etc ; make cmp )
|
||||
(cd util ; make cmp )
|
||||
(cd lang ; make cmp )
|
||||
(cd mach ; make cmp )
|
||||
|
||||
install: # compile everything to machine code
|
||||
(cd etc ; make install )
|
||||
(cd util ; make install )
|
||||
(cd lang/cem ; make install )
|
||||
(cd mach ; make install )
|
||||
(cd lang/pc ; make install )
|
||||
|
||||
clean: # remove all non-sources, except boot-files
|
||||
(cd doc ; make clean )
|
||||
(cd man ; make clean )
|
||||
(cd h ; make clean )
|
||||
(cd etc ; make clean )
|
||||
(cd util ; make clean )
|
||||
(cd lang ; make clean )
|
||||
(cd mach ; make clean )
|
||||
|
||||
opr: # print all sources
|
||||
make pr | opr
|
||||
|
||||
pr: # print all sources
|
||||
@( pr Makefile ; \
|
||||
(cd doc ; make pr ) ; \
|
||||
(cd man ; make pr ) ; \
|
||||
(cd h ; make pr ) ; \
|
||||
(cd etc ; make pr ) ; \
|
||||
(cd lang ; make pr ) ; \
|
||||
(cd util ; make pr ) ; \
|
||||
(cd mach ; make pr ) \
|
||||
)
|
||||
17
NEW
Normal file
17
NEW
Normal file
@@ -0,0 +1,17 @@
|
||||
What's new:
|
||||
A lot of things have changed since that previous distribution.
|
||||
It is not wise to mix files created by the previous version of the Kit
|
||||
with files belonging to this version, although that might sometimes work.
|
||||
The major additions are:
|
||||
- Basic frontend
|
||||
- New codegenerator
|
||||
- LL(1) parser generator
|
||||
- Vax backend with 4-byte wordsize
|
||||
- Motorola 68000 backend with 4-byte wordsize
|
||||
- Motorola 68000 interpreter for 2- and 4-byte wordsize
|
||||
- Z8000 assembler and backend.
|
||||
- 6805 assembler
|
||||
- NatSem 16032 assembler
|
||||
- Intel 8080 backend
|
||||
- Zilog Z80 backend
|
||||
- Signetics 2650 assembler
|
||||
2
README
Normal file
2
README
Normal file
@@ -0,0 +1,2 @@
|
||||
Before starting installation you should read
|
||||
the file doc/install.pr
|
||||
109
TakeAction
Executable file
109
TakeAction
Executable file
@@ -0,0 +1,109 @@
|
||||
case $# in
|
||||
0) PAR=install ; CMD=Action ;;
|
||||
1) PAR="$1" ; CMD=Action ;;
|
||||
2) PAR="$1" ; CMD="$2" ;;
|
||||
*) echo Syntax: "$0" [param [file]] ; exit 1 ;;
|
||||
esac
|
||||
if test -r "$CMD"
|
||||
then :
|
||||
else
|
||||
case "$CMD" in
|
||||
Action) echo No Action file present ;;
|
||||
*) echo No Action file "($CMD)" present ;;
|
||||
esac
|
||||
fi
|
||||
THISFILE=`pwd`/$0
|
||||
SYS=
|
||||
RETC=0
|
||||
{ while read LINE
|
||||
do
|
||||
eval set $LINE
|
||||
case x"$1" in
|
||||
x#*) ;;
|
||||
xname) SYS="$2"
|
||||
ACTION='make $PAR'
|
||||
DIR=.
|
||||
FM=no
|
||||
FAIL='Failed for $SYS, see $DIR/Out'
|
||||
SUCC='$SYS -- done'
|
||||
ATYPE=
|
||||
FATAL=no
|
||||
DOIT=yes
|
||||
;;
|
||||
xfatal) FATAL=yes ;;
|
||||
xaction|xindir) case x$ATYPE in
|
||||
x) ACTION=$2 ; ATYPE=$1
|
||||
case $ATYPE$FM in
|
||||
indirno) FAIL='Failed for $SYS' ;;
|
||||
esac
|
||||
;;
|
||||
*) echo Already specified an $ATYPE for this name
|
||||
RETC=65 ;;
|
||||
esac ;;
|
||||
xfailure) FM=yes
|
||||
FAIL="$2" ;;
|
||||
xsuccess) SUCC="$2" ;;
|
||||
xdir) DIR="$2" ;;
|
||||
xsystem) case `ack_sys` in
|
||||
$2) ;;
|
||||
*) echo "Sorry, $SYS can only be made on $2 systems"
|
||||
DOIT=no
|
||||
;;
|
||||
esac ;;
|
||||
xend) case $DOIT in
|
||||
no) continue ;;
|
||||
esac
|
||||
case x$SYS in
|
||||
x) echo Missing name line; RETC=65 ;;
|
||||
*) if test -d $DIR
|
||||
then (
|
||||
cd $DIR
|
||||
X=
|
||||
case $ATYPE in
|
||||
indir)
|
||||
if sh $THISFILE $PAR $ACTION
|
||||
then eval echo $SUCC
|
||||
else RETC=2 ; eval echo $FAIL
|
||||
fi ;;
|
||||
*)
|
||||
if eval "$ACTION >Out 2>&1 </dev/null"
|
||||
then eval echo $SUCC
|
||||
else RETC=1 ; X=: ; eval echo $FAIL
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
(echo ------- `pwd`
|
||||
cat Out
|
||||
$X rm -f Out
|
||||
) 2>/dev/null 1>&- 1>&3
|
||||
exit $RETC
|
||||
)
|
||||
case $? in
|
||||
0) ;;
|
||||
*) case $RETC in
|
||||
0) RETC=$? ;;
|
||||
esac ;;
|
||||
esac
|
||||
else
|
||||
echo Directory $DIR for $SYS is inaccessible
|
||||
RETC=66
|
||||
fi ;;
|
||||
esac
|
||||
case $FATAL$RETC in
|
||||
yes0) ;;
|
||||
yes*) echo Fatal error, installation stopped.
|
||||
exit $RETC ;;
|
||||
esac
|
||||
SYS=
|
||||
;;
|
||||
*) echo Unknown keyword "$1"
|
||||
RETC=67 ;;
|
||||
esac
|
||||
done
|
||||
exit $RETC
|
||||
} <$CMD
|
||||
RETX=$?
|
||||
case $RETX in
|
||||
0) exit $RETC ;;
|
||||
*) exit $RETX ;;
|
||||
esac
|
||||
1
bin/em.pascal
Executable file
1
bin/em.pascal
Executable file
@@ -0,0 +1 @@
|
||||
exec /usr/em/doc/em.doc/int/em /usr/em/doc/em.doc/int/tables ${1-e.out} core
|
||||
15
distr/Action
Normal file
15
distr/Action
Normal file
@@ -0,0 +1,15 @@
|
||||
name "Installation manual"
|
||||
dir doc
|
||||
end
|
||||
name "EM documentation"
|
||||
dir doc/em.doc
|
||||
end
|
||||
name "Pascal bootstrap files"
|
||||
dir lang/pc/pem
|
||||
end
|
||||
name "LLgen bootstrap files"
|
||||
dir util/LLgen
|
||||
end
|
||||
name "MSC6500 vend_library"
|
||||
dir mach/6500/libem
|
||||
end
|
||||
6
distr/Action1
Normal file
6
distr/Action1
Normal file
@@ -0,0 +1,6 @@
|
||||
name "vax2/cg bootstrap files"
|
||||
dir mach/vax2/cg
|
||||
end
|
||||
name "vax4/cg bootstrap files"
|
||||
dir mach/vax4/cg
|
||||
end
|
||||
42
distr/Exceptions
Normal file
42
distr/Exceptions
Normal file
@@ -0,0 +1,42 @@
|
||||
-- ./bin/em.pascal no RCS file
|
||||
-- ./doc/em.doc/doc.pr no RCS file
|
||||
-- ./doc/install.pr no RCS file
|
||||
-- ./h/em_mnem.h no RCS file
|
||||
-- ./h/em_pseu.h no RCS file
|
||||
-- ./h/em_spec.h no RCS file
|
||||
-- ./lang/basic/src/y.tab.c no RCS file
|
||||
-- ./lang/basic/src/y.tab.h no RCS file
|
||||
-- ./lang/pc/pem/pem22.m no RCS file
|
||||
-- ./lang/pc/pem/pem24.m no RCS file
|
||||
-- ./lib/LLgen/incl no RCS file
|
||||
-- ./lib/LLgen/rec no RCS file
|
||||
-- ./lib/ix/head_em no RCS file
|
||||
-- ./lib/ix/head_i no RCS file
|
||||
-- ./lib/ix/tail_em no RCS file
|
||||
-- ./lib/ix/tail_em.vend no RCS file
|
||||
-- ./lib/ix/tail_mon no RCS file
|
||||
-- ./mach/6500/libem/tail_em.ve.s.a no RCS file
|
||||
-- ./mach/vax2/cg/tables1.c no RCS file
|
||||
-- ./mach/vax2/cg/tables1.h no RCS file
|
||||
-- ./mach/vax4/cg/tables1.c no RCS file
|
||||
-- ./mach/vax4/cg/tables1.h no RCS file
|
||||
-- ./mach/z80/int/libpc/pc_tail.c.a no RCS file
|
||||
-- ./mkun/pubmac no distr2 yet
|
||||
-- ./mkun/tmac.q no distr2 yet
|
||||
-- ./mkun/tmac.q1 no distr2 yet
|
||||
-- ./mkun/tmac.q2 no distr2 yet
|
||||
-- ./mkun/tmac.q3 no distr2 yet
|
||||
-- ./mkun/tmac.q4 no distr2 yet
|
||||
-- ./mkun/tmac.q5 no distr2 yet
|
||||
-- ./mkun/tmac.q6 no distr2 yet
|
||||
-- ./mkun/tmac.q7 no distr2 yet
|
||||
-- ./mkun/tmac.q8 no distr2 yet
|
||||
-- ./util/LLgen/src/parser no RCS file
|
||||
-- ./util/LLgen/src/LLgen.c no RCS file
|
||||
-- ./util/LLgen/src/Lpars.c no RCS file
|
||||
-- ./util/LLgen/src/Lpars.h no RCS file
|
||||
-- ./util/LLgen/src/tokens.c no RCS file
|
||||
-- ./util/data/em_flag.c no RCS file
|
||||
-- ./util/data/em_mnem.c no RCS file
|
||||
-- ./util/data/em_pseu.c no RCS file
|
||||
-- ./util/data/em_ptyp.c no RCS file
|
||||
74
distr/How_To
Normal file
74
distr/How_To
Normal file
@@ -0,0 +1,74 @@
|
||||
How to make a fresh distribution:
|
||||
For a distribution you need ".distr" files and RCS files.
|
||||
The EM home directory contains a file called ".distr". It contains
|
||||
the names of all the files and directories you want to have in the distribution.
|
||||
The directories should contain .distr files, the other files should
|
||||
be placed under RCS.
|
||||
The current RCS revision name is "distr2".
|
||||
The are files that derive from other files and yet should be placed
|
||||
in the distribution.
|
||||
These files should not be placed under RCS.
|
||||
The file "Exceptions" in this directory contains the current list of
|
||||
these files.
|
||||
|
||||
When all this is correct, use the shell script mktree the extract
|
||||
the distribution from the EM tree.
|
||||
cd /usr/em ; sh distr/mktree destination_tree >distr/f.attf 2>&1
|
||||
Make sure that the destination tree exists and is empty!
|
||||
Failing to do that will almost certainly result in a welter of
|
||||
error messages.
|
||||
The file f.attf contains mktree error messages and should be compared
|
||||
to Exceptions.
|
||||
The actions of mktree are quite complicated. It starts in the current
|
||||
directory reading the ".distr" file, after copying that file to the
|
||||
destination tree.
|
||||
For each file mentioned there it performes certain actions:
|
||||
1- Directory Change to that directory and call yourself recursively.
|
||||
2- File
|
||||
a- Try to do "co -rdistr2 destination_tree/path/destination_file"
|
||||
on succes "chmod +w destination_file"
|
||||
else
|
||||
b- Try to do "co destination_tree/destination_file"
|
||||
on succes "chmod +w destination_file" and
|
||||
give message that says "Missing distr2 entry" (or some such).
|
||||
else
|
||||
c- I Does a file LIST exist in this directory AND
|
||||
is the first line of LIST equal to the name of the
|
||||
destination file? If so, try to extract all the files
|
||||
named in the rest of the LIST file and call the program
|
||||
arch to create a library "arch cr `cat LIST`".
|
||||
In this manner libraries can be distributed whose members
|
||||
have their own RCS file!
|
||||
else
|
||||
II try to do "cp file destination_tree/path/destination_file"
|
||||
on succes give message that says "Missing RCS entry"
|
||||
(or some such).
|
||||
else
|
||||
d-
|
||||
give message that says "Missing entry" (or some such).
|
||||
|
||||
Now you have the tree but not everything is kosher yet.
|
||||
Some files derive from other files in the tree, those derivations should
|
||||
be done with the use of an already installed distribution.
|
||||
The files Action and Action1 in this directory contain the actions
|
||||
we now take. (Confession: most of the time we use /usr/em)
|
||||
One warning, to re-nroff the IR-81 report it takes more then just nroff
|
||||
because most nroff's can't stand that report and stop half-way.
|
||||
The ntroff program does the trick, but only on the 11's.
|
||||
tbl sources | ntroff -Tlp | ntlp
|
||||
|
||||
After running these re-derivation programs the distrubtion tree starts
|
||||
to look like the tree you need.
|
||||
There are too many files there though, especially the files created by
|
||||
the derivation process.
|
||||
That is why we now give the command:
|
||||
dtar cdf distr2 .
|
||||
The file distr2 is the one you should put on tape!
|
||||
But,.... before doing that: Try it out!
|
||||
Repeat the process described in the installation manual.
|
||||
Only if that succeeds you are sure that you included the files needed,
|
||||
and gave all other files the correct "distr2" RCS id.
|
||||
After you sent the tape away, forbid ANYBODY to touch the distr2 id
|
||||
in your RCS files.
|
||||
Good Luck,
|
||||
Ed Keizer, 85/4/15.
|
||||
25
distr/dwalk
Executable file
25
distr/dwalk
Executable file
@@ -0,0 +1,25 @@
|
||||
: ${CDIR=.}
|
||||
if test ! -r .distr
|
||||
then
|
||||
echo ++ no .distr in $CDIR
|
||||
exit 0
|
||||
fi
|
||||
${DS-:} $CDIR
|
||||
for i in `cat .distr`
|
||||
do
|
||||
if test -d $i
|
||||
then
|
||||
( if cd $i
|
||||
then
|
||||
${DD-:} $CDIR $i
|
||||
CDIR=$CDIR/$i
|
||||
export CDIR
|
||||
exec /usr/em/distr/dwalk
|
||||
else
|
||||
echo ++ Could not access $CDIR/$i
|
||||
fi
|
||||
)
|
||||
else
|
||||
${DF-:} $CDIR $i
|
||||
fi
|
||||
done
|
||||
1
distr/echod
Executable file
1
distr/echod
Executable file
@@ -0,0 +1 @@
|
||||
echo $1/$2
|
||||
42
distr/f.attf
Normal file
42
distr/f.attf
Normal file
@@ -0,0 +1,42 @@
|
||||
-- ./bin/em.pascal no RCS file
|
||||
-- ./doc/em.doc/doc.pr no RCS file
|
||||
-- ./doc/install.pr no RCS file
|
||||
-- ./h/em_mnem.h no RCS file
|
||||
-- ./h/em_pseu.h no RCS file
|
||||
-- ./h/em_spec.h no RCS file
|
||||
-- ./lang/basic/src/y.tab.c no RCS file
|
||||
-- ./lang/basic/src/y.tab.h no RCS file
|
||||
-- ./lang/pc/pem/pem22.m no RCS file
|
||||
-- ./lang/pc/pem/pem24.m no RCS file
|
||||
-- ./lib/LLgen/incl no RCS file
|
||||
-- ./lib/LLgen/rec no RCS file
|
||||
-- ./lib/ix/head_em no RCS file
|
||||
-- ./lib/ix/head_i no RCS file
|
||||
-- ./lib/ix/tail_em no RCS file
|
||||
-- ./lib/ix/tail_em.vend no RCS file
|
||||
-- ./lib/ix/tail_mon no RCS file
|
||||
-- ./mach/6500/libem/tail_em.ve.s.a no RCS file
|
||||
-- ./mach/vax2/cg/tables1.c no RCS file
|
||||
-- ./mach/vax2/cg/tables1.h no RCS file
|
||||
-- ./mach/vax4/cg/tables1.c no RCS file
|
||||
-- ./mach/vax4/cg/tables1.h no RCS file
|
||||
-- ./mach/z80/int/libpc/pc_tail.c.a no RCS file
|
||||
-- ./mkun/pubmac no distr2 yet
|
||||
-- ./mkun/tmac.q no distr2 yet
|
||||
-- ./mkun/tmac.q1 no distr2 yet
|
||||
-- ./mkun/tmac.q2 no distr2 yet
|
||||
-- ./mkun/tmac.q3 no distr2 yet
|
||||
-- ./mkun/tmac.q4 no distr2 yet
|
||||
-- ./mkun/tmac.q5 no distr2 yet
|
||||
-- ./mkun/tmac.q6 no distr2 yet
|
||||
-- ./mkun/tmac.q7 no distr2 yet
|
||||
-- ./mkun/tmac.q8 no distr2 yet
|
||||
-- ./util/LLgen/src/parser no RCS file
|
||||
-- ./util/LLgen/src/LLgen.c no RCS file
|
||||
-- ./util/LLgen/src/Lpars.c no RCS file
|
||||
-- ./util/LLgen/src/Lpars.h no RCS file
|
||||
-- ./util/LLgen/src/tokens.c no RCS file
|
||||
-- ./util/data/em_flag.c no RCS file
|
||||
-- ./util/data/em_mnem.c no RCS file
|
||||
-- ./util/data/em_pseu.c no RCS file
|
||||
-- ./util/data/em_ptyp.c no RCS file
|
||||
10
distr/listall
Executable file
10
distr/listall
Executable file
@@ -0,0 +1,10 @@
|
||||
case $# in
|
||||
0) DIR=. ;;
|
||||
1) DIR=$1 ;;
|
||||
*) echo $0 [directory] ; exit 1 ;;
|
||||
esac
|
||||
DD=`pwd`/listall.d
|
||||
DW=`pwd`/dwalk
|
||||
export DD
|
||||
cd $DIR
|
||||
$DW
|
||||
2
distr/listall.d
Executable file
2
distr/listall.d
Executable file
@@ -0,0 +1,2 @@
|
||||
echo "<$1/$2>"
|
||||
ls -bCdx `cat .distr`
|
||||
10
distr/listdirs
Executable file
10
distr/listdirs
Executable file
@@ -0,0 +1,10 @@
|
||||
case $# in
|
||||
0) DIR=. ;;
|
||||
1) DIR=$1 ;;
|
||||
*) echo $0 [directory] ; exit 1 ;;
|
||||
esac
|
||||
DD=`pwd`/echod
|
||||
DW=`pwd`/dwalk
|
||||
export DD
|
||||
cd $DIR
|
||||
$DW
|
||||
9
distr/mka
Executable file
9
distr/mka
Executable file
@@ -0,0 +1,9 @@
|
||||
set -e
|
||||
for i in `tail +2 $DESTDIR/$1/LIST`
|
||||
do
|
||||
${DF-false} $1 $i
|
||||
done
|
||||
cd $DESTDIR/$1
|
||||
arch cr `cat LIST`
|
||||
: I do not remove the files constituating the library, because
|
||||
: they might be present in .distr
|
||||
23
distr/mkf
Executable file
23
distr/mkf
Executable file
@@ -0,0 +1,23 @@
|
||||
if co -q -rdistr2 $DESTDIR/$1/$2 >/dev/null 2>&1
|
||||
then
|
||||
chmod +w $DESTDIR/$1/$2
|
||||
elif co -q $DESTDIR/$1/$2 >/dev/null 2>&1
|
||||
then
|
||||
chmod +w $DESTDIR/$1/$2
|
||||
echo -- $1/$2 no distr2 yet
|
||||
elif grep LIST .distr >/dev/null 2>&1 &&
|
||||
(test "$2" = "`head -1 $DESTDIR/$1/LIST`") >/dev/null 2>&1 &&
|
||||
${DA-false} "$1" "$2"
|
||||
then
|
||||
: Fetched library contents one by one and put them together
|
||||
elif cp $2 $DESTDIR/$1/$2 >/dev/null 2>&1
|
||||
then
|
||||
echo -- $1/$2 no RCS file
|
||||
else
|
||||
echo ++ $1/$2 not present
|
||||
fi
|
||||
case $2 in
|
||||
LIST) if (test -r $DESTDIR/$1/`head -1 $DESTDIR/$1/LIST`) >/dev/null 2>&1
|
||||
then echo ++ LIST files must be in .distr before their libraries!!!
|
||||
fi ;;
|
||||
esac
|
||||
15
distr/mktree
Normal file
15
distr/mktree
Normal file
@@ -0,0 +1,15 @@
|
||||
case $# in
|
||||
1) ;;
|
||||
*) echo $0 directory ; exit 1 ;;
|
||||
esac
|
||||
DDIR=/usr/em/distr
|
||||
case $1 in
|
||||
/*) DESTDIR=$1 ;;
|
||||
*) DESTDIR=`pwd`/$1 ;;
|
||||
esac
|
||||
DS=$DDIR/mks
|
||||
DD=$DDIR/mkd
|
||||
DF=$DDIR/mkf
|
||||
DA=$DDIR/mka
|
||||
export DESTDIR DS DD DF DA
|
||||
$DDIR/dwalk
|
||||
26
distr/todistr
Normal file
26
distr/todistr
Normal file
@@ -0,0 +1,26 @@
|
||||
REV=
|
||||
FILE=
|
||||
while :
|
||||
do
|
||||
case $# in
|
||||
0) break ;;
|
||||
esac
|
||||
ARG="$1"
|
||||
shift
|
||||
case "$ARG" in
|
||||
-r*) REV=`echo "$ARG"| sed s/-r//` ;;
|
||||
-*) FLAGS="$FLAGS $ARG" ;;
|
||||
*) case x$FILE in
|
||||
x) FILE="$ARG" ;;
|
||||
*) echo todistr can only be done on one file at the time
|
||||
exit 1 ;;
|
||||
esac
|
||||
esac
|
||||
done
|
||||
case x$REV in
|
||||
x) REV=`rlog -h "$FILE"|sed -n -e '/head/s/^head:[ ]*//p'` ;;
|
||||
esac
|
||||
case x$REV in
|
||||
x) exit 2 ;;
|
||||
esac
|
||||
rcs -ndistr2:$REV $FLAGS $FILE
|
||||
2163
doc/6500.doc
Normal file
2163
doc/6500.doc
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ SUF=pr
|
||||
PRINT=cat
|
||||
RESFILES=cref.$(SUF) pcref.$(SUF) val.$(SUF) v7bugs.$(SUF) install.$(SUF)\
|
||||
ack.$(SUF) cg.$(SUF) regadd.$(SUF) peep.$(SUF) toolkit.$(SUF) LLgen.$(SUF)\
|
||||
basic.$(SUF)
|
||||
basic.$(SUF) 6500.$(SUF) ncg.$(SUF)
|
||||
NROFF=nroff
|
||||
MS=-ms
|
||||
|
||||
@@ -16,6 +16,8 @@ ack.$(SUF): ack.doc
|
||||
$(NROFF) $(MS) $? >$@
|
||||
cg.$(SUF): cg.doc
|
||||
$(NROFF) $(MS) $? >$@
|
||||
ncg.$(SUF): ncg.doc
|
||||
$(NROFF) $(MS) $? >$@
|
||||
regadd.$(SUF): regadd.doc
|
||||
$(NROFF) $(MS) $? >$@
|
||||
install.$(SUF): install.doc
|
||||
@@ -32,9 +34,13 @@ toolkit.$(SUF): toolkit.doc
|
||||
$(NROFF) $(MS) $? >$@
|
||||
LLgen.$(SUF): LLgen.doc
|
||||
eqn $? | $(NROFF) $(MS) >$@
|
||||
6500.$(SUF): 6500.doc
|
||||
$(NROFF) $(MS) $? >$@
|
||||
|
||||
install cmp:
|
||||
|
||||
distr: install.doc
|
||||
nroff -Tlp install.doc >install.pr
|
||||
pr:
|
||||
@make "SUF="$SUF "NROFF="$NROFF "PRINT="$PRINT $(RESFILES) \
|
||||
>make.pr.out 2>&1
|
||||
|
||||
@@ -51,11 +51,8 @@ ordered alphabetically.
|
||||
Appendix A discusses the differences with
|
||||
Microsoft BASIC. Appendix B describes all reserved symbols.
|
||||
Appendix C lists the error messages in use.
|
||||
.sp
|
||||
Additional information about EM and the Amsterdam Compiler Kit
|
||||
can be obtained from .... and found in ......
|
||||
.SH
|
||||
SyNTAX NOTATION
|
||||
SYNTAX NOTATION
|
||||
.LP
|
||||
The conventions for syntax presentation are as follows:
|
||||
.IP CAPS 10
|
||||
@@ -80,8 +77,6 @@ GENERAL INFORMATION
|
||||
The BASIC-EM compiler is designed for a UNIX based environment.
|
||||
It accepts a text file with your BASIC program (suffix .b) and generates
|
||||
an executable file, called a.out.
|
||||
.LP
|
||||
Should we call the preprocessor first?
|
||||
.NH 2
|
||||
LINE FORMAT
|
||||
.LP
|
||||
@@ -145,7 +140,7 @@ Defines a double precision variable
|
||||
Defines a string variable.
|
||||
.LP
|
||||
NOTE: Two variables with the same name but different type is
|
||||
considered illegal (DONE?).
|
||||
considered illegal.
|
||||
.LP
|
||||
Beside single valued variables, values may be grouped
|
||||
into tables or arrays.
|
||||
@@ -542,7 +537,7 @@ MID$
|
||||
MID$(<string expr1>,n[,m])=<string expr2>
|
||||
.PU
|
||||
To replace a portion of a string with another string value.
|
||||
The characters of <string expr> replaces characters in <string expr1>
|
||||
The characters of <string expr2> replaces characters in <string expr1>
|
||||
starting at position n. If m is present, at most m characters are copied,
|
||||
otherwise all characters are copied.
|
||||
However, the string obtained never exceeds the length of string expr1.
|
||||
|
||||
62
doc/cref.doc
62
doc/cref.doc
@@ -133,6 +133,8 @@ properties of the Ack-C frontend.
|
||||
.IT "2.2 Identifiers"
|
||||
External identifiers are unique up to 7 characters and allow
|
||||
both upper and lower case.
|
||||
.IT "2.3 Keywords"
|
||||
The word \fBvoid\fP is also reserved as a keyword.
|
||||
.IT "2.4.3 Character constants"
|
||||
The ASCII-mapping is used when a character is converted to an
|
||||
integer.
|
||||
@@ -140,11 +142,12 @@ integer.
|
||||
To prevent loss of precision the compiler does not perform
|
||||
floating point constant folding.
|
||||
.IT "2.6 Hardware characteristics"
|
||||
The size of objects of the several arithmetic types and the two
|
||||
pointer types depend on the EM-implementation used.
|
||||
The size of objects of the several arithmetic types and
|
||||
pointers depend on the EM-implementation used.
|
||||
The ranges of the arithmetic types depend on the size used,
|
||||
the C-frontend assumes two's complement representation for the
|
||||
integral types. All sizes are multiples of bytes.
|
||||
integral types.
|
||||
All sizes are multiples of bytes.
|
||||
The calling program \fIack\fP[4] passes information about the
|
||||
size of the types to the compiler proper.
|
||||
.br
|
||||
@@ -152,32 +155,27 @@ However, a few general remarks must be made:
|
||||
.sp 1
|
||||
.IS
|
||||
.PT (a)
|
||||
Two different pointer types exist: pointers to data and
|
||||
pointers to functions.
|
||||
The latter type is twice as large as the former.
|
||||
Pointers to functions use the same format as Pascal procedure
|
||||
parameters, thereby allowing C to use Pascal procedure
|
||||
parameters and vice-versa.
|
||||
The extra information passed indicates the scope level of the
|
||||
procedure.
|
||||
.PT (b)
|
||||
The size of pointers to data is a multiple of
|
||||
The size of pointers is a multiple of
|
||||
(or equal to) the size of an \fIint\fP.
|
||||
.PT (c)
|
||||
.PT (b)
|
||||
The following relations exist for the sizes of the types
|
||||
mentioned:
|
||||
.br
|
||||
.ti +5
|
||||
\fIchar<=short<=int<=long\fP
|
||||
.PT (d)
|
||||
.PT (c)
|
||||
Objects of type \fIchar\fP use one 8-bit byte of storage,
|
||||
although several bytes are allocated sometimes.
|
||||
.PT (e)
|
||||
.PT (d)
|
||||
All sizes are in multiples of bytes.
|
||||
.PT (f)
|
||||
.PT (e)
|
||||
Most EM implementations use 4 bytes for floats and 8 bytes
|
||||
for doubles, but exceptions to this rule occur.
|
||||
.IE
|
||||
.IT "4 What's in a name"
|
||||
The type \fIvoid\fP is added.
|
||||
Objects of type void do not exist.
|
||||
Functions declared as returning void, do not return a value at all.
|
||||
.IT "6.1 Characters and integers"
|
||||
Objects of type \fIchar\fP are unsigned and do not cause
|
||||
sign-extension when converted to \fIint\fP.
|
||||
@@ -187,8 +185,16 @@ Floating point numbers are truncated towards zero when
|
||||
converted to the integral types.
|
||||
.IT "6.4 Pointers and integers"
|
||||
When a \fIlong\fP is added to or subtracted from a pointer and
|
||||
longs are larger then data pointers the \fIlong\fP is converted to an
|
||||
longs are larger then pointers the \fIlong\fP is converted to an
|
||||
\fIint\fP before the operation is performed.
|
||||
.IT "7.2 Unary operators"
|
||||
It is allowed to cast any expression to the type \fIvoid\fP.
|
||||
.IT "8.2 Type specifiers"
|
||||
One type is added to the type-specifiers:
|
||||
.br
|
||||
.IS
|
||||
void
|
||||
.IE
|
||||
.IT "8.5 Structure and union declarations"
|
||||
The only type allowed for fields is \fIint\fP.
|
||||
Fields with exactly the size of \fIint\fP are signed,
|
||||
@@ -200,8 +206,15 @@ Initialization of structures containing bit fields is not
|
||||
allowed.
|
||||
There is one restriction when using an 'address expression' to initialize
|
||||
an integral variable.
|
||||
The integral variable must have the size of a data pointer.
|
||||
The integral variable must have the same size as a pointer.
|
||||
Conversions altering the size of the address expression are not allowed.
|
||||
.IT "9.10 Return statement"
|
||||
Return statements of the form:
|
||||
.IS
|
||||
return ;
|
||||
.IE
|
||||
are the only form of return statement allowed in a function of type
|
||||
function returning void.
|
||||
.IT "10.1 External function definitions"
|
||||
The total amount for storage used for parameters
|
||||
in any function must be less then 4096 bytes.
|
||||
@@ -227,15 +240,8 @@ int and back will not always result in the same pointer.
|
||||
The process mentioned above works with integrals
|
||||
of the same size or larger as pointers in all EM implementations
|
||||
having such integrals.
|
||||
Note that pointers to functions have
|
||||
twice the size of pointers to data.
|
||||
When converting data pointers to an integral type or vice-versa,
|
||||
the pointers is seen as an unsigned with the same size a data-pointer.
|
||||
When converting function pointers to anything else the static link part
|
||||
of the pointer is discarded,
|
||||
the resulting value is treated as if it were a data pointer.
|
||||
When converting a data pointer or object of integral type to a function pointer
|
||||
a static link with the value 0 is added to complete the function pointer.
|
||||
When converting pointers to an integral type or vice-versa,
|
||||
the pointers is seen as an unsigned int.
|
||||
.br
|
||||
EM guarantees that any object can be placed at a word boundary,
|
||||
this allows the C-programs to use \fIint\fP pointers
|
||||
|
||||
@@ -7,6 +7,9 @@ IOP=../../util/ass/ip_spec.t
|
||||
doc.pr: $(FILES) itables em.i
|
||||
tbl $(FILES) | $(NROFF) >doc.pr
|
||||
|
||||
distr: $(FILES) itables em.i
|
||||
tbl $(FILES) | nroff -Tlp >doc.pr
|
||||
|
||||
opr: doc.pr
|
||||
make pr | opr
|
||||
|
||||
|
||||
@@ -388,6 +388,17 @@ May not be preceded by any other pseudo, except MES's.
|
||||
.PT "MES 9,<cst>"
|
||||
Guarantees that no more than <cst> bytes of parameters are
|
||||
accessed, either directly or indirectly.
|
||||
.PT "MES 10,<cst>[,<par>]*
|
||||
This message number is reserved for the global optimizer.
|
||||
It inserts these messages in its output as hints to backends.
|
||||
<cst> indicates the type of hint.
|
||||
.PT "MES 11"
|
||||
Procedures containing this message are possible destinations of
|
||||
non-local goto's with the GTO instruction.
|
||||
Some backends keep locals in registers,
|
||||
the locals in this procedure should not be kept in registers and
|
||||
all registers containing locals of other procedures should be
|
||||
saved upon entry to this procedure.
|
||||
.PE 1
|
||||
.VS 1 1
|
||||
Each backend is free to skip irrelevant MES pseudos.
|
||||
@@ -561,7 +572,7 @@ l l 15 l l.
|
||||
\&\*n:cst:>= 0:counter
|
||||
\&\*s:cst:>0 , word multiple:object size
|
||||
\&\*z:cst:>= 0 , zero or word multiple:object size
|
||||
\&\*o:cst:>= 0 , word multiple or fraction:object size
|
||||
\&\*o:cst:> 0 , word multiple or fraction:object size
|
||||
\&\*w:cst:> 0 , word multiple:object size *
|
||||
\&\*p:pro::pro identifier
|
||||
\&\*b:ilb:>= 0:label number
|
||||
|
||||
@@ -240,7 +240,7 @@ begin if (a<0) or (a>maxoffs)
|
||||
end;
|
||||
|
||||
function argo(a:double):size;
|
||||
begin if (a<0) or (a>maxoffs)
|
||||
begin if (a<=0) or (a>maxoffs)
|
||||
then trap(EODDZ)
|
||||
else if (a mod wsize<>0) and (wsize mod a<>0) then trap(EODDZ);
|
||||
argo:=a ;
|
||||
|
||||
@@ -281,7 +281,7 @@ begin if (a<0) or (a>maxoffs)
|
||||
end;
|
||||
|
||||
function argo(a:double):size;
|
||||
begin if (a<0) or (a>maxoffs)
|
||||
begin if (a<=0) or (a>maxoffs)
|
||||
then trap(EODDZ)
|
||||
else if (a mod wsize<>0) and (wsize mod a<>0) then trap(EODDZ);
|
||||
argo:=a ;
|
||||
@@ -683,7 +683,7 @@ begin
|
||||
a:=argp(uerrorproc);
|
||||
uerrorproc:=0; { reset signal }
|
||||
call(a); { call the routine }
|
||||
intrap:=false; { Don't catch recursive traps anymore }
|
||||
intrap:=false; { Do not catch recursive traps anymore }
|
||||
goto 8888; { reenter main loop }
|
||||
end;
|
||||
|
||||
@@ -1149,7 +1149,7 @@ end;
|
||||
jmp (r2) /done
|
||||
|
||||
The important thing to notice is where and how the operand fetch occurred:
|
||||
lol2, lol4, and lol6, (the mini's) have implicit operands
|
||||
lol2, lol4, and lol6, (the minis) have implicit operands
|
||||
lolb knew it had to fetch one byte, and did so without any table lookup
|
||||
lolw knew it had to fetch a word, and did so, high order byte first }
|
||||
{
|
||||
@@ -1604,10 +1604,9 @@ begin
|
||||
end;
|
||||
CSA: begin k:=argw(k); if k<>wsize then trap(EILLINS);
|
||||
a:=popa;
|
||||
st:= popsw - signwd(memw(a+asize)); b:=0;
|
||||
st:= popsw - signwd(memw(a+asize));
|
||||
if (st>=0) and (st<=memw(a+wsize+asize)) then
|
||||
b:=mema(a+2*wsize+asize+asize*st);
|
||||
if b=0 then b:=mema(a);
|
||||
b:=mema(a+2*wsize+asize+asize*st) else b:=mema(a);
|
||||
if b=0 then trap(ECASE) else newpc(b)
|
||||
end;
|
||||
CSB: begin k:=argw(k); if k<>wsize then trap(EILLINS); a:=popa;
|
||||
|
||||
@@ -45,6 +45,7 @@ the trapping instruction (see next chapter).
|
||||
the GTO instruction, which is used for non-local goto's.
|
||||
It can remove several frames from the stack and transfer
|
||||
control to an active procedure.
|
||||
(see also MES~11 in paragraph 11.1.4.4)
|
||||
.PE
|
||||
.IE
|
||||
.P
|
||||
|
||||
830
doc/i80.doc
Normal file
830
doc/i80.doc
Normal file
@@ -0,0 +1,830 @@
|
||||
." $Header$
|
||||
.RP
|
||||
.TL
|
||||
Back end table for the Intel 8080 micro-processor
|
||||
.AU
|
||||
Gerard Buskermolen
|
||||
.AB
|
||||
A back end is a part of the Amsterdam Compiler Kit (ACK).
|
||||
It translates EM, a family of intermediate languages, into the
|
||||
assembly language of some target machine, here the Intel 8080 and Intel 8085 microprocessors.
|
||||
.AE
|
||||
.NH1
|
||||
INTRODUCTION
|
||||
.PP
|
||||
To simplify the task of producing portable (cross) compilers and
|
||||
interpreters, the Vrije Universiteit designed an integrated collection
|
||||
of programs, the Amsterdam Compiler Kit (ACK).
|
||||
It is based on the old UNCOL-idea ([4]) which attempts to solve the problem
|
||||
of making a compiler for each of
|
||||
.B N
|
||||
languages on
|
||||
.B M
|
||||
different machines without having to write
|
||||
.B N\ *\ M
|
||||
programs.
|
||||
.sp 1
|
||||
The UNCOL approach is to write
|
||||
.B N
|
||||
"front ends", each of which translates one source language into
|
||||
a common intermediate language, UNCOL (UNiversal Computer Oriented
|
||||
Language), and
|
||||
.B M
|
||||
"back ends", each of which translates programs in UNCOL into a
|
||||
specific machine language.
|
||||
Under these conditions, only
|
||||
.B N\ +\ M
|
||||
programs should be written to provide all
|
||||
.B N
|
||||
languages on all
|
||||
.B M
|
||||
machines, instead of
|
||||
.B N\ *\ M
|
||||
programs.
|
||||
.sp 1
|
||||
The intermediate language for the Amsterdam Compiler Kit is the machine
|
||||
language for a simple stack machine called EM (Encoding Machine).
|
||||
So a back end for the Intel 8080 micro translates EM code into
|
||||
8080 assembly language.
|
||||
.sp 1
|
||||
The back end is a single program that is driven by a machine dependent
|
||||
driving table.
|
||||
This driving table, or back end table,
|
||||
defines the mapping from EM code to the machine's assembly language.
|
||||
.NH 1
|
||||
THE 8080 MICRO PROCESSOR
|
||||
.PP
|
||||
This back end table can be used without modification for the Intel 8085
|
||||
processor.
|
||||
Except for two additional instructions, the 8085 instruction set
|
||||
is identical and fully compatible with the 8080 instruction set.
|
||||
So everywhere in this document '8080' can be read as '8080 and 8085'.
|
||||
.NH 2
|
||||
Registers
|
||||
.PP
|
||||
The 8080 processor has an 8 bit accumulator,
|
||||
six general purpose 8-bit registers,
|
||||
a 16 bit programcounter and a 16 bit stackpointer.
|
||||
Assembler programs can refer the accumulator by A and
|
||||
the general purpose registers by B, C, D, E, H and L. (*)
|
||||
.FS
|
||||
* In this document 8080 registers and mnemonics are referenced by capitals, for the sake of clarity.
|
||||
Nevertheless the assembler expects small letters.
|
||||
.FE
|
||||
Several instructions address registers in groups of two, thus creating
|
||||
16 bit registers:
|
||||
.DS
|
||||
Registers referenced: Symbolic reference:
|
||||
B and C B
|
||||
D and E D
|
||||
H and L H
|
||||
.DE
|
||||
The first named register, contains the high order byte
|
||||
(H and L stand for High and Low).
|
||||
.br
|
||||
The instruction determines how the processor interprets the reference.
|
||||
For example, ADD B is an 8 bit operation, adding the contents of
|
||||
register B to accumulator A. By contrast PUSH B is a 16 bit operation
|
||||
pushing B and C onto the stack.
|
||||
.sp 1
|
||||
There are no index registers.
|
||||
.sp 1
|
||||
.NH 2
|
||||
Flip-flops
|
||||
.PP
|
||||
The 8080 microprocessor provides five flip-flops used as condition flags
|
||||
(S, Z, P, C, AC) and one interrupt enable flip-flop IE.
|
||||
.br
|
||||
The sign bit S is set (cleared) by certain instructions when the most significant
|
||||
bit of the result of an operation equals one (zero).
|
||||
.br
|
||||
The zero bit Z is set (cleared) by certain operations when the
|
||||
8-bit result of an operation equals (does not equal) zero.
|
||||
.br
|
||||
The parity bit P is set (cleared) if the 8-bit result of an
|
||||
operation includes an even (odd) number of ones.
|
||||
.br
|
||||
C is the normal carry bit.
|
||||
.br
|
||||
AC is an auxiliary carry that indicates whether there has been a carry
|
||||
out of bit 3 of the accumulator.
|
||||
This auxiliary carry is used only by the DAA instruction, which
|
||||
adjusts the 8-bit value in the accumulator to form two 4-bit
|
||||
binary coded decimal digits.
|
||||
Needless to say this instruction is not used in the back-end.
|
||||
.sp 1
|
||||
The interrupt enable flip-flop IE is set and cleared under
|
||||
program control using the instructions EI (Enable Interrupt) and
|
||||
DI (Disable Interrupt).
|
||||
It is automatically cleared when the CPU is reset and when
|
||||
an interrupt occurs, disabling further interrupts until IE = 1 again.
|
||||
.NH 2
|
||||
Addressing modes
|
||||
.NH 3
|
||||
Implied addressing
|
||||
.PP
|
||||
The addressing mode of some instructions is implied by the instruction itself.
|
||||
For example, the RAL (rotate accumulator left) instruction deals only with
|
||||
the accumulator, and PCHL loads the programcounter with the contents
|
||||
of register-pair HL.
|
||||
.NH 3
|
||||
Register addressing
|
||||
.PP
|
||||
|
||||
With each intruction using register addressing,
|
||||
only one register is specified (except for the MOV instruction),
|
||||
although in many of them the accumulator is implied as
|
||||
second operand.
|
||||
Examples are CMP E, which compares register E with the accumulator,
|
||||
and DCR B, which decrements register B.
|
||||
.br
|
||||
A few instructions deal with 16 bit register-pairs:
|
||||
examples are DCX B, which decrements register-pair BC and the
|
||||
PUSH and POP instructions.
|
||||
.NH 3
|
||||
Register indirect addressing
|
||||
.PP
|
||||
Each instruction that may refer to an 8 bit register, may
|
||||
refer also to a memory location. In this case the letter M
|
||||
(for Memory) has to be used instead of a register.
|
||||
It indicates the memory location pointed to by H and L,
|
||||
so ADD M adds the contents of the memory location specified
|
||||
by H and L to the contents of the accumulator.
|
||||
.br
|
||||
The register-pairs BC and DE can also be used for indirect addressing,
|
||||
but only to load or store the accumulator.
|
||||
For example, STAX B stores the contents of the accumulator
|
||||
into the memory location addressed by register-pair BC.
|
||||
.NH 3
|
||||
Immediate addressing
|
||||
.PP
|
||||
The immediate value can be an 8 bit value, as in ADI 10 which
|
||||
adds 10 to the accumulator, or a 16 bit value, as in
|
||||
LXI H,1000, which loads 1000 in the register-pair HL.
|
||||
.NH 3
|
||||
Direct addressing
|
||||
.PP
|
||||
Jump instructions include a 16 bit address as part of the instruction.
|
||||
.br
|
||||
The instruction SHLD 1234 stores the contents of register
|
||||
pair HL on memory locations 1234 and 1235.
|
||||
The high order byte is stored at the highest address.
|
||||
.NH 1
|
||||
THE 8080 BACK END TABLE
|
||||
.PP
|
||||
The back end table is designed as described in [5].
|
||||
So for an overall design of a back end table I refer to this document.
|
||||
.br
|
||||
This section deals with problems encountered in writing the
|
||||
8080 back-end table.
|
||||
Some remarks are made about particular parts
|
||||
of the table that might not seem clear at first sight.
|
||||
.NH 2
|
||||
Constant definitions
|
||||
.PP
|
||||
Word size (EM_WSIZE) and pointer size (EM_PSIZE) are both
|
||||
defined as two bytes.
|
||||
The hole between AB and LB (EM_BSIZE) is four bytes: only the
|
||||
return address and the localbase are saved.
|
||||
.NH 2
|
||||
Registers and their properties
|
||||
.PP
|
||||
All properties have the default size of two bytes, because one-byte
|
||||
registers also cover two bytes when put on the real stack.
|
||||
.sp 1
|
||||
The next considerations led to the choise of register-pair BC
|
||||
as localbase.
|
||||
Though saving the localbase in memory would leave one more register-pair
|
||||
available as scratch register, it would slow down instructions
|
||||
as 'lol' and 'stl' too much.
|
||||
So a register-pair should be sacrificed as localbase.
|
||||
Because a back-end without a free register-pair HL is completely
|
||||
broken-winged, the only reasonable choises are BC and DE.
|
||||
Though the choise between them might seem arbitrary at first sight,
|
||||
there is a difference between register-pairs BC and DE:
|
||||
the instruction XCHG exchanges the contents of register-pairs DE and
|
||||
HL.
|
||||
When DE and HL are both heavily used on the fake-stack, this instruction
|
||||
is very usefull.
|
||||
Since it won't be usefull too often to exchange HL with the localbase
|
||||
and since an instruction exchanging BC and HL does not exist, BC is
|
||||
chosen as localbase.
|
||||
.sp 1
|
||||
Many of the register properties are never mentioned in the
|
||||
PATTERNS part of the table.
|
||||
They are only needed to define the INSTRUCTIONS correctly.
|
||||
.sp 1
|
||||
The properties really used in the PATTERNS part are:
|
||||
.IP areg: 24
|
||||
the accumulator only
|
||||
.IP reg:
|
||||
any of the registers A, D, E, H or L. Of course the registers B and C which are
|
||||
used as localbase don't possess this property.
|
||||
When there is a single register on the fake-stack, its value
|
||||
is always considered non-negative.
|
||||
.IP dereg:
|
||||
register-pair DE only
|
||||
.IP hlreg:
|
||||
register-pair HL only
|
||||
.IP hl_or_de:
|
||||
register-pairs HL and DE both have this property
|
||||
.IP localbase:
|
||||
used only once (i.e. in the EM-instruction 'str 0')
|
||||
.PP
|
||||
.sp 1
|
||||
The stackpointer SP and the processor status word PSW have to be
|
||||
defined explicitely because they are needed in some instructions
|
||||
(i.e. SP in LXI, DCX and INX and PSW in PUSH and POP).
|
||||
.br
|
||||
It doesn't matter that the processor status word is not just register A
|
||||
but includes the condition flags.
|
||||
.NH 2
|
||||
Tokens
|
||||
.PP
|
||||
The tokens 'm' and 'const1' are used in the INSTRUCTIONS- and MOVES parts only.
|
||||
They will never be on the fake-stack.
|
||||
.sp 1
|
||||
The token 'label' reflects addresses known at assembly time.
|
||||
It is used to take full profit of the instructions LHLD
|
||||
(Load HL Direct) and SHLD (Store HL Direct).
|
||||
.sp 1
|
||||
Compared with many other back-end tables, there are only a small number of
|
||||
different tokens (four).
|
||||
Reasons are the limited addressing modes of the 8080 microprocessor,
|
||||
no index registers etc.
|
||||
.br
|
||||
For example to translate the EM-instruction
|
||||
.DS
|
||||
lol 10
|
||||
.DE
|
||||
the next 8080 instructions are generated:
|
||||
.DS L
|
||||
LXI H,10 /* load registers pair HL with value 10 */
|
||||
DAD B /* add localbase (BC) to HL */
|
||||
MOV E,M /* load E with byte pointed to by HL */
|
||||
INX H /* increment HL */
|
||||
MOV D,M /* load D with next byte */
|
||||
.DE
|
||||
Of course, instead of emitting code immmediately, it could be postponed
|
||||
by placing something like a {LOCAL,10} on the fake-stack, but some day the above
|
||||
mentioned code will have to be generated, so a LOCAL-token is
|
||||
hardly usefull.
|
||||
.br
|
||||
See also the comment on the load instructions.
|
||||
.NH 2
|
||||
Sets
|
||||
.PP
|
||||
Only 'src1or2' is used in the PATTERNS.
|
||||
.NH 2
|
||||
Instructions
|
||||
.PP
|
||||
Each instruction indicates whether or not the condition flags
|
||||
are affected, but this information will never have any influence
|
||||
because there are no tests in the PATTERNS part of the table.
|
||||
.sp 1
|
||||
For each instruction a cost vector indicates the number of bytes
|
||||
the instruction occupies and the number of time periods it takes
|
||||
to execute the instruction.
|
||||
The length of a time period depends on the clock frequency
|
||||
and may range from 480 nanoseconds to 2 microseconds on a
|
||||
8080 system and from 320 nanoseconds to 2 microseconds
|
||||
on a 8085 system.
|
||||
.sp 1
|
||||
In the TOKENS-part the cost of token 'm' is defined as (0,3).
|
||||
In fact it usually takes 3 extra time periods when this register indirect mode
|
||||
is used instead of register mode, but since the costs are not completely
|
||||
orthogonal this results in small deficiencies for the DCR, INR and MOV
|
||||
instructions.
|
||||
Although it is not particularly usefull these deficiencies are
|
||||
corrected in the INSTRUCTIONS part, by treating the register indirect
|
||||
mode seperately.
|
||||
.sp 1
|
||||
The costs of the conditional call and return instructions really
|
||||
depend on whether or not the call resp. return is actually made.
|
||||
Unimportant.
|
||||
.sp 1
|
||||
Instructions not used in this table have been commented out.
|
||||
Of course many of them are used in the library routines.
|
||||
.NH 2
|
||||
Moves
|
||||
.PP
|
||||
This section is supposed to be straight-forward.
|
||||
.NH 2
|
||||
Tests
|
||||
.PP
|
||||
The TESTS section is only included to refrain
|
||||
.B cgg
|
||||
from complaining.
|
||||
.NH 2
|
||||
Stackingrules
|
||||
.PP
|
||||
When, for example, the token {const2,10} has to be stacked while
|
||||
no free register-pair is available, the next code is generated:
|
||||
.DS
|
||||
PUSH H
|
||||
LXI H,10
|
||||
XTHL
|
||||
.DE
|
||||
The last instruction exchanges the contents of HL with the value
|
||||
on top of the stack, giving HL its original value again.
|
||||
.NH 2
|
||||
Coercions
|
||||
.PP
|
||||
The coercion to unstack register A, is somewhat tricky,
|
||||
but unfortunately just popping PSW leaves the high-order byte in
|
||||
the accumulator.
|
||||
.sp 1
|
||||
The cheapest way to coerce HL to DE (or DE to HL) is by using
|
||||
the XCHG instruction, but it is not possible to explain
|
||||
.B cgg
|
||||
this instruction in fact exchanges the contents of these
|
||||
register-pairs.
|
||||
Before the coercion is carried out other appearances of DE and HL
|
||||
on the fake-stack will be moved to the real stack, because in
|
||||
the INSTRUCTION-part is told that XCHG destroyes the contents
|
||||
of both DE and HL.
|
||||
.br
|
||||
The coercion transposing one register-pair to another one by
|
||||
emitting two MOV-instructions, will be used only if
|
||||
one of the register-pairs is the localbase.
|
||||
.NH 2
|
||||
Patterns
|
||||
.PP
|
||||
As a general habit I have allocated (uses ...) all registers
|
||||
that should be free to generate the code, although it is not
|
||||
always necessary.
|
||||
For example in the code rule
|
||||
.DS
|
||||
pat loe
|
||||
uses hlreg
|
||||
gen lhld {label,$1} yields hl
|
||||
.DE
|
||||
the 'uses'-clause could have been omitted because
|
||||
.B cgg
|
||||
knows that LHLD destroyes register-pair HL.
|
||||
.sp 1
|
||||
Since there is only one register with property 'hlreg',
|
||||
there is no difference between 'uses hlreg' (allocate a
|
||||
register with property 'hlreg') and 'kills hlreg' (remove
|
||||
all registers with property 'hlreg' from the fake-stack).
|
||||
The same applies for the property 'dereg'.
|
||||
.br
|
||||
As a consequence 'kills' is rarely used in this back-end table.
|
||||
.NH 3
|
||||
Group 1: Load instructions
|
||||
.PP
|
||||
When a local variable must be squared, there will probably be EM-code like:
|
||||
.DS
|
||||
lol 10
|
||||
lol 10
|
||||
mli 2
|
||||
.DE
|
||||
When the code for the first 'lol 10' has been executed, DE contains the
|
||||
wanted value.
|
||||
To refrain
|
||||
.B cgg
|
||||
from emitting the code for 'lol 10' again, an extra
|
||||
pattern is included in the table for cases like this.
|
||||
.br
|
||||
The same applies for two consecutive 'loe'-s or 'lil'-s.
|
||||
.sp 1
|
||||
A bit tricky is 'lof'.
|
||||
It expects either DE or HL on the fake-stack, moves {const2,$1}
|
||||
into the other one, and eventually adds them.
|
||||
The 'kills' part is necessary here because if DE was on the fake-stack,
|
||||
.B cgg
|
||||
doesn't see that the contents of DE is destroyed by the code
|
||||
(in fact 'kills dereg' would have been sufficient: because of the
|
||||
DAD instruction
|
||||
.B cgg
|
||||
knows that HL is destroyed).
|
||||
.sp 1
|
||||
By lookahead,
|
||||
.B cgg
|
||||
can make a clever choise between the first and
|
||||
second code rule of 'loi 4'.
|
||||
The same applies for several other instructions.
|
||||
.NH 3
|
||||
Group 2: Store instructions
|
||||
.PP
|
||||
A similar idea as with the two consecutive identical load instructions
|
||||
in Group 1, applies for a store instruction followed by a corresponding load instruction.
|
||||
.NH 3
|
||||
Groups 3 and 4: Signed and unsigned integer arithmetic
|
||||
.PP
|
||||
Since the 8080 instruction set doesn't provide multiply and
|
||||
divide instructions, special routines are made to accomplish these tasks.
|
||||
.sp 1
|
||||
Instead of providing four slighty differing routines for 16 bit signed or
|
||||
unsigned division, yielding the quotient or the remainder,
|
||||
the routines are merged.
|
||||
This saves space and assembly time
|
||||
when several variants are used in a particular program,
|
||||
at the cost of a little speed.
|
||||
.br
|
||||
When the routine is called, bit 7 of register A indicates whether
|
||||
the operands should be considered as signed or as unsigned integers,
|
||||
and bit 0 of register A indicates whether the quotient or the
|
||||
remainder has to be delivered.
|
||||
.br
|
||||
The same applies for 32 bit division.
|
||||
.sp 1
|
||||
The routine doing the 16 bit unsigned multiplication could
|
||||
have been used for 16 bit signed multiplication too.
|
||||
Nevertheless a special 16 bit signed multiplication routine is
|
||||
provided, because this one will usually be much faster.
|
||||
.NH 3
|
||||
Group 5: Floating point arithmetic
|
||||
.PP
|
||||
Floating points are not implemented.
|
||||
.br
|
||||
Whenever an EM-instruction involving floating points is offered
|
||||
to the code-generator, it generates the code 'call eunimpl',
|
||||
which traps with trap number 63.
|
||||
Some of the Pascal and C library routines output floating point
|
||||
EM-instructions, so code has to be generated for them.
|
||||
Of course this doesn't imply the code will ever be executed.
|
||||
.NH 3
|
||||
Group 12: Compare instructions
|
||||
.PP
|
||||
The code for 'cmu 2', with its 4 labels, is terrible.
|
||||
But it is the best I could find.
|
||||
.NH 3
|
||||
Group 9: Logical instructions
|
||||
.PP
|
||||
I have tried to merge both variants of the instructions 'and 2', 'ior 2' and 'xor 2',
|
||||
as in
|
||||
.DS
|
||||
pat and $1==2
|
||||
with hl_or_de hl_or_de
|
||||
uses reusing %1, reusing %2, hl_or_de, areg
|
||||
gen mov a,%1.2
|
||||
ana %2.2
|
||||
mov %a.2,a
|
||||
mov a,%1.1
|
||||
ana %2.1
|
||||
mov %a.1,a yields %a
|
||||
.DE
|
||||
but the current version of
|
||||
.B cgg
|
||||
doesn't approve this.
|
||||
.br
|
||||
In any case
|
||||
.B cgg
|
||||
chooses either DE or HL to store the result, using lookahead.
|
||||
.NH 3
|
||||
Group 14: Procedure call instructions
|
||||
.PP
|
||||
There is an 8 bytes function return area, called '.fra'.
|
||||
If only 2 bytes have to be returned, register-pair DE is used.
|
||||
.NH 1
|
||||
LIBRARY ROUTINES
|
||||
.PP
|
||||
Most of the library routines start with saving the return address
|
||||
and the localbase, so that the parameters are on the top of the stack
|
||||
and the registers B and C are available as scratch registers.
|
||||
Since register-pair HL is needed to accomplish these tasks,
|
||||
and also to restore everything just before the routine returns,
|
||||
it is not possible to transfer data between the routines and the
|
||||
surrounding world through register H or L.
|
||||
Only registers A, D and E can be used for this.
|
||||
.sp
|
||||
When a routine returns 2 bytes, they are usually returned in
|
||||
registers-pair DE.
|
||||
When it returns more than 2 bytes they are pushed onto the stack.
|
||||
.br
|
||||
|
||||
It would have been possible to let the 32 bit arithmetic routines
|
||||
return 2 bytes in DE and the remaining 2 bytes on the stack
|
||||
(this often would have saved some space and execution time),
|
||||
but I don't consider that as well-structured programming.
|
||||
.NH 1
|
||||
TRAPS
|
||||
.PP
|
||||
Whenever a trap, for example trying to divide by zero,
|
||||
occurs in a program that originally was written in C or Pascal,
|
||||
a special trap handler is called.
|
||||
.br
|
||||
This trap handler wants to write an appropriate error message on the
|
||||
monitor.
|
||||
It tries to read the message from a file (e.g. etc/pc_rt_errors in the
|
||||
EM home directory for Pascal programs), but since the 8080 back-end
|
||||
doesn't know about files, we are in trouble.
|
||||
This problem is solved, as far as possible, by including the 'open'-monitor call in the mon-routine.
|
||||
It returns with file descriptor -1.
|
||||
The trap handler reacts by generating another trap, with the original
|
||||
trap number.
|
||||
But this time, instead of calling the C- or Pascal trap handler again,
|
||||
the next message is printed on the monitor:
|
||||
.DS L
|
||||
trap number <TN>
|
||||
line <LN> of file <FN>
|
||||
|
||||
where <TN> is the trap number (decimal)
|
||||
<LN> is the line number (decimal)
|
||||
<FN> is the filename of the original program
|
||||
.DE
|
||||
.sp 1
|
||||
Trap numbers are subdivided as follows:
|
||||
.IP 1-27: 20
|
||||
EM-machine error, as described in [3]
|
||||
.IP 63:
|
||||
an unimplemented EM-instruction is used
|
||||
.IP 64-127:
|
||||
generated by compilers, runtime systems, etc.
|
||||
.IP 128-252:
|
||||
generated by user programs
|
||||
.NH 1
|
||||
IMPLEMENTATION
|
||||
.PP
|
||||
It will not be possible to run the entire Amsterdam Compiler Kit on a
|
||||
8080-based computer system.
|
||||
One has to write a program on another
|
||||
system, a system where the compiler kit runs on.
|
||||
This program may be a mixture of high-level languages, such as
|
||||
C or Pascal, EM and 8080 assembly code.
|
||||
The program should be compiled using the compiler kit, producing 8080 machine code.
|
||||
This code should come available to the 8080 machine
|
||||
for example by downloading or
|
||||
by storing it in ROM (Read Only Memory).
|
||||
.sp 1
|
||||
Depending on the characteristics of the particular 8080 based system, some
|
||||
adaptions have to be made:
|
||||
.IP 1) 10
|
||||
In 'head_em': the base address, which is the address where the first
|
||||
8080 instruction will be stored, and the initial value of the
|
||||
stackpointer are set to 0x1000 and 0x8000 respectivally.
|
||||
.br
|
||||
Other systems require other values.
|
||||
.IP 2)
|
||||
In 'head_em': before calling "_m_a_i_n", the environment
|
||||
pointer, argument vector and argument count will have to be pushed
|
||||
onto the stack.
|
||||
Since this back-end is tested on a system without any knowledge
|
||||
of these things, dummies are pushed now.
|
||||
.IP 3)
|
||||
In 'tail_em': proper routines "putchar" and "getchar" should
|
||||
be provided.
|
||||
They should write resp. read a character on/from the monitor.
|
||||
Maybe some conversions will have to be made.
|
||||
.IP 4)
|
||||
In 'head_em': an application program returns control to the monitor by
|
||||
jumping to address 0xFB52.
|
||||
If this is not the right way on your system, change it.
|
||||
.IP 5)
|
||||
In 'tail_em': the current version of the 8080 back-end has very limited I/O
|
||||
capabilities, because it was tested on a system that
|
||||
had no knowlegde of files.
|
||||
So the implementation of the EM-instruction 'mon' is very simple;
|
||||
it can only do the following things:
|
||||
.RS
|
||||
.IP Monitor\ call\ 1: 40
|
||||
Exit
|
||||
.IP Monitor\ call\ 3:
|
||||
read, always reads from the monitor.
|
||||
.br
|
||||
echos the read character.
|
||||
.br
|
||||
ignores file descriptor.
|
||||
.IP Monitor\ call\ 4:
|
||||
write, always writes on the monitor.
|
||||
.br
|
||||
ignores file descriptor.
|
||||
.IP Monitor\ call\ 5:
|
||||
open file, returns file descriptor -1.
|
||||
.br
|
||||
(compare chapter about TRAPS)
|
||||
.IP Monitor\ call\ 6:
|
||||
close file, returns error code = 0.
|
||||
.IP Monitor\ call\ 54:
|
||||
io-control, returns error code = 0.
|
||||
.RE
|
||||
.sp
|
||||
If the system should do file-handling the routine ".mon"
|
||||
should be extended thoroughly.
|
||||
.NH 1
|
||||
INTEL 8080 VERSUS ZILOG Z80 AND INTEL 8086
|
||||
.NH 2
|
||||
Introduction
|
||||
.PP
|
||||
At about the same time I develloped the back end
|
||||
for the Intel 8080 and Intel 8085,
|
||||
Frans van Haarlem did the same job for the Zilog z80 microprocessor.
|
||||
Since the z80 processor is an extension of the 8080,
|
||||
any machine code offered to a 8080 processor can be offered
|
||||
to a z80 too.
|
||||
The assembly languages are quite different however.
|
||||
.br
|
||||
During the devellopments of the back ends we have used
|
||||
two micro-computers, both equiped with a z80 microprocessor.
|
||||
Of course the output of the 8080 back end is assembled by an
|
||||
8080 assembler. This should assure I have never used any of
|
||||
the features that are potentially available in the z80 processor,
|
||||
but are not part of a true 8080 processor.
|
||||
.sp 1
|
||||
As a final job, I have
|
||||
investigated the differences between the 8080 and z80 processors
|
||||
and their influence on the back ends.
|
||||
I have tried to measure this influence by examining the length of
|
||||
the generated code.
|
||||
I have also involved the 8086 micro-processor in this measurements.
|
||||
.NH 2
|
||||
Differences between the 8080 and z80 processors
|
||||
.PP
|
||||
Except for some features that are less important concerning back ends,
|
||||
there are two points where the z80 improves the 8080:
|
||||
.IP First, 18
|
||||
the z80 has two additional index registers, IX and IY.
|
||||
They are used as in
|
||||
.DS
|
||||
LD B,(IX+10)
|
||||
.DE
|
||||
The offset, here 10, should fit in one byte.
|
||||
.IP Second,
|
||||
the z80 has several additional instructions.
|
||||
The most important ones are:
|
||||
.RS
|
||||
.IP 1) 8
|
||||
The 8080 can only load or store register-pair HL direct
|
||||
(using LHLD or SHLD).
|
||||
The z80 can handle BC, DE and SP too.
|
||||
.IP 2)
|
||||
Instructions are included to ease block movements.
|
||||
.IP 3)
|
||||
There is a 16 bit subtract instruction.
|
||||
.IP 4)
|
||||
While the 8080 can only rotate the accumulator, the z80
|
||||
can rotate and shift each 8 bit register.
|
||||
.IP 5)
|
||||
Special routines are included to jump to near locations, saving 1 byte.
|
||||
.RE
|
||||
.NH 2
|
||||
Consequences for the 8080 and z80 back end
|
||||
.PP
|
||||
The most striking difference between the 8080 and z80 back ends
|
||||
is the choise of the localbase.
|
||||
The writer of the z80 back end chose index register IY as localbase,
|
||||
because this results in the cheapest coding of EM-instructions
|
||||
like 'lol' and 'stl'.
|
||||
.br
|
||||
The z80 instructions that load local 10, for example
|
||||
.DS
|
||||
LD E,(IY+10)
|
||||
LD D,(IY+11)
|
||||
.DE
|
||||
occupy 6 bytes and take 38 time periods to execute.
|
||||
The five corresponding 8080 instructions loading a local
|
||||
occupy 7 bytes and take 41 time periods.
|
||||
Although the profit of the z80 might be not world-shocking,
|
||||
it should be noted that as a side effect it may save some
|
||||
pushing and popping since register pair HL is not used.
|
||||
.sp 1
|
||||
The choise of IY as localbase has its drawbacks too.
|
||||
The root of the problem is that it is not possible to add
|
||||
IY to HL.
|
||||
For the EM-instruction
|
||||
.DS
|
||||
lal 20
|
||||
.DE
|
||||
the z80 back end generates code like
|
||||
.DS
|
||||
LD BC,20
|
||||
PUSH IY
|
||||
POP HL
|
||||
ADD HL,BC
|
||||
.DE
|
||||
leaving the wanted address in HL.
|
||||
.br
|
||||
This annoying push and pop instructions are also needed in some
|
||||
other instructions, for instance in 'lol' when the offset
|
||||
doesn't fit in one byte.
|
||||
.sp 1
|
||||
Beside the choise of the localbase, I think there is no
|
||||
fundamental difference between the 8080 and z80 back ends,
|
||||
except of course that the z80 back end has register pair BC
|
||||
and, less important, index register IX available as scratch registers.
|
||||
.sp 1
|
||||
Most of the PATTERNS in the 8080 and z80 tables are more or less
|
||||
a direct translation of each other.
|
||||
.NH 2
|
||||
What did I do?
|
||||
.PP
|
||||
To get an idea of the quality of the code generated by
|
||||
the 8080, z80 and 8086 back ends I have gathered
|
||||
some C programs and some Pascal programs.
|
||||
Then I produced 8080, z80 and 8086 code for them.
|
||||
Investigating the assembler listing I found the
|
||||
lengths of the different parts of the generated code.
|
||||
.br
|
||||
I have checked two areas:
|
||||
.IP 1) 8
|
||||
the entire text part
|
||||
.IP 2)
|
||||
the text part without any library routine, so only the plain user program
|
||||
.LP
|
||||
I have to admit that neither one of them is really honest.
|
||||
When the entire text part is checked, the result is disturbed
|
||||
because not always the same library routines are loaded.
|
||||
And when only the user program itself is considered, the result is
|
||||
disturbed too.
|
||||
For example the 8086 has a multiply instruction,
|
||||
so the EM-instruction 'mli 2' is translated in the main program,
|
||||
but the 8080 and z80 call a library routine that is not counted.
|
||||
Also the 8080 uses library routines at some places where the
|
||||
z80 does not.
|
||||
.sp 1
|
||||
But nevertheless I think the measurements will give an idea
|
||||
about the code produced by the three back ends.
|
||||
.NH 2
|
||||
The results
|
||||
.PP
|
||||
The table below should be read as follows.
|
||||
For all programs I have computed the ratio of the code-lengths
|
||||
of the 8080, z80 and 8086.
|
||||
The averages of all Pascal/C programs are listed in the table,
|
||||
standarized to '100' for the 8080.
|
||||
So the listed '107' indicates that the lengths
|
||||
of the text parts of the z80 programs that originally were Pascal programs,
|
||||
averaged 7 percent larger than in the corresponding 8080 programs.
|
||||
.DS C
|
||||
--------------------------------------------------
|
||||
| | 8080 | z80 | 8086 |
|
||||
--------------------------------------------------
|
||||
| C, text part | 100 | 103 | 65 |
|
||||
| Pascal, text part | 100 | 107 | 55 |
|
||||
| C, user program | 100 | 110 | 71 |
|
||||
| Pascal, user program | 100 | 118 | 67 |
|
||||
--------------------------------------------------
|
||||
.DE
|
||||
.TE
|
||||
The most striking thing in this table is that the z80 back end appears
|
||||
to produce larger code than the 8080 back end.
|
||||
The reason is that the current z80 back end table is
|
||||
not very elaborate yet.
|
||||
For instance it doesn't look for any EM-pattern longer than one.
|
||||
So the table shows that the preparations in the 8080 back end table
|
||||
to produce faster code (like recognizing special EM-patterns
|
||||
and permitting one byte registers on the fake-stack)
|
||||
was not just for fun, but really improved the generated code
|
||||
significantly.
|
||||
.sp 1
|
||||
The table shows that the 8080 table is relativelly better
|
||||
when only the plain user program is considered instead of the entire text part.
|
||||
This is not very surprising since the 8080 back end sometimes
|
||||
uses library routines where the z80 and especially the 8086 don't.
|
||||
.sp 1
|
||||
The difference between the 8080 and z80 on the one hand and the 8086
|
||||
on the other is very big.
|
||||
But of course it was not equal game:
|
||||
the 8086 is a 16 bit processor that is much more advanced than the
|
||||
8080 or z80 and the 8086 back end is known to produce
|
||||
very good code.
|
||||
.bp
|
||||
.B REFERENCES
|
||||
.sp 2
|
||||
.IP [1] 10
|
||||
8080/8085 Assembly Language Programming Manual,
|
||||
.br
|
||||
Intel Corporation (1977,1978)
|
||||
.IP [2]
|
||||
Andrew S. Tanenbaum, Hans van Staveren, E.G. Keizer and Johan W. Stevenson,
|
||||
.br
|
||||
A practical tool kit for making portable compilers,
|
||||
.br
|
||||
Informatica report 74, Vrije Universiteit, Amsterdam, 1983.
|
||||
.sp
|
||||
An overview on the Amsterdam Compiler Kit.
|
||||
.IP [3]
|
||||
Tanenbaum, A.S., Stevenson, J.W., Keizer, E.G., and van Staveren, H.
|
||||
.br
|
||||
Desciption of an experimental machine architecture for use with block
|
||||
structured languages,
|
||||
.br
|
||||
Informatica report 81, Vrije Universiteit, Amsterdam, 1983.
|
||||
.sp
|
||||
The defining document for EM.
|
||||
.IP [4]
|
||||
Steel, T.B., Jr.
|
||||
.br
|
||||
UNCOL: The myth and the Fact. in Ann. Rev. Auto. Prog.
|
||||
.br
|
||||
Goodman, R. (ed.), vol. 2, (1960), p325-344.
|
||||
.sp
|
||||
An introduction to the UNCOL idea by its originator.
|
||||
.IP [5]
|
||||
van Staveren, Hans
|
||||
.br
|
||||
The table driven code generator from the Amsterdam Compiler Kit
|
||||
(Second Revised Edition),
|
||||
.br
|
||||
Vrije Universiteit, Amsterdam.
|
||||
.sp
|
||||
The defining document for writing a back end table.
|
||||
.IP [6]
|
||||
Voors, Jan
|
||||
.br
|
||||
A back end for the Zilog z8000 micro,
|
||||
.br
|
||||
Vrije Universiteit, Amsterdam.
|
||||
.sp
|
||||
A document like this one, but for the z8000.
|
||||
1077
doc/install.doc
1077
doc/install.doc
File diff suppressed because it is too large
Load Diff
2948
doc/ncg.doc
Normal file
2948
doc/ncg.doc
Normal file
File diff suppressed because it is too large
Load Diff
@@ -413,6 +413,36 @@ for parameters. Some EM implementations check this:
|
||||
\*(ONnot checked.
|
||||
.I2
|
||||
not checked.
|
||||
.IE
|
||||
.PP
|
||||
For those who wish the use the interface between C and Pascal we
|
||||
give an incomplete list of corresponding formal parameters in C and Pascal.
|
||||
.sp 1
|
||||
.ta 8 37
|
||||
.nf
|
||||
Pascal C
|
||||
a:integer int a
|
||||
a:char int a
|
||||
a:boolean int a
|
||||
a:real double a
|
||||
a:^type type *a
|
||||
var a:type type *a
|
||||
procedure a(pars) struct {
|
||||
void (*a)() ;
|
||||
char *static_link ;
|
||||
}
|
||||
function a(pars):type struct {
|
||||
type (*a)() ;
|
||||
char *static_link ;
|
||||
}
|
||||
.fi
|
||||
The Pascal runtime system uses the following algorithm when calling
|
||||
function/procedures passed as parameters.
|
||||
.nf
|
||||
.ta 8 16
|
||||
if ( static_link ) (*a)(static_link,pars) ;
|
||||
else (*a)(pars) ;
|
||||
.fi
|
||||
.IT 6.7.2.1
|
||||
The order of evaluation of the operands of a dyadic operator
|
||||
shall be implementation-dependent.
|
||||
@@ -1304,6 +1334,19 @@ Alternate symbol representation.
|
||||
.sp
|
||||
The comment delimiters '(*' and '*)' are recognized and treated like '{' and '}'.
|
||||
The other alternate representations of symbols are not recognized.
|
||||
.sp
|
||||
.ti -3
|
||||
9.~\
|
||||
Pre-processing.
|
||||
.sp
|
||||
If the very first character of a file containing a Pascal
|
||||
program is the sharp ('#', ASCII 23(hex)) the file is preprocessed
|
||||
in the same way as C programs.
|
||||
Lines beginning with a '#' are taken as preprocessor command lines
|
||||
and not fed to the Pascal compiler proper.
|
||||
C style comments, /*......*/, are removed by the C preprocessor,
|
||||
thus C comments inside Pascal programs are also removed when they
|
||||
are fed through the preprocessor.
|
||||
.CH "Deviations from the standard"
|
||||
Ack-Pascal deviates from the (March 1980) standard proposal in the following ways:
|
||||
.IS
|
||||
|
||||
68
doc/z80.doc
Normal file
68
doc/z80.doc
Normal file
@@ -0,0 +1,68 @@
|
||||
THE Z80 BACK END TABLE
|
||||
|
||||
INTRODUCTION
|
||||
|
||||
This table was written to make it run, not to make it clever!
|
||||
The effect is, that the table written for the intel 8080,
|
||||
which was made very clever runs faster and requiers less space!!
|
||||
So, for anyone to run programs on a z80 machine:
|
||||
You could try to make the table as clever as the one for the i80,
|
||||
or you could run the i80 table, for that can run on every z80 too.
|
||||
|
||||
IMPLEMENTATION
|
||||
|
||||
It will not be possible to run the entire Amsterdam Compiler Kit on a
|
||||
Z80-based computer system.
|
||||
One has to write a program on another
|
||||
system, a system where the compiler kit runs on.
|
||||
This program may be a mixture of high-level languages, such as
|
||||
C or Pascal, EM and z80 assembly code.
|
||||
The program should be compiled using the compiler kit,
|
||||
producing z80 machine code.
|
||||
This code should come available to the z80 machine
|
||||
for example by downloading or
|
||||
by storing it in ROM (Read Only Memory).
|
||||
Depending on the characteristics of the particular z80 based system, some
|
||||
adaptions have to be made:
|
||||
1) In 'head_em': the base address, which is the address where the first
|
||||
z80 instruction will be stored, and the initial value of the
|
||||
stackpointer are set to 0x1000 and 0x7ffe respectivally.
|
||||
The latter because it could run on a 32K machine as well.
|
||||
Other systems require other values.
|
||||
2) In 'head_em': before calling "_m_a_i_n", the environment
|
||||
pointer, argument vector and argument count will have to be pushed
|
||||
onto the stack.
|
||||
Since this back-end is tested on a system without any knowledge
|
||||
of these things, dummies are pushed now.
|
||||
3) In 'tail_em': proper routines "putchar" and "getchar" should
|
||||
be provided.
|
||||
They should write resp. read a character on/from the monitor.
|
||||
Maybe some conversions will have to be made.
|
||||
The ones for the Nascom and Hermac z80 micro's are to be found
|
||||
in the EM-library.
|
||||
4) In 'head_em': an application program returns control to the monitor by
|
||||
jumping to address 0x20.
|
||||
If this is not the right way on your system, change it.
|
||||
For an CPM-machine for example this should be 0x5, to provide a warm boot.
|
||||
5) In 'tail_em': the current version of the z80 back-end has very limited I/O
|
||||
capabilities, because it was tested on a system that
|
||||
had no knowlegde of files.
|
||||
So the implementation of the EM-instruction 'mon' is very simple;
|
||||
it can only do the following things:
|
||||
Monitor call 1:
|
||||
Exit
|
||||
Monitor call 3:
|
||||
read, always reads from the monitor.
|
||||
echos the read character.
|
||||
ignores file descriptor.
|
||||
Monitor call 4:
|
||||
write, always writes on the monitor.
|
||||
ignores file descriptor.
|
||||
Monitor call 5:
|
||||
open file, returns file descriptor -1.
|
||||
Monitor call 6:
|
||||
close file, returns error code = 0.
|
||||
Monitor call 54:
|
||||
io-control, returns error code = 0.
|
||||
If the system should do file-handling the routine ".mon"
|
||||
should be extended thoroughly.
|
||||
19
emtest/Makefile
Normal file
19
emtest/Makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
tested: last
|
||||
set -x ;\
|
||||
for i in `awk '{for(i=\$$1;i<=127;i++)print i}' last ` ;\
|
||||
do \
|
||||
echo $$i; \
|
||||
echo $$i >last; \
|
||||
select $$i tests > test.e; \
|
||||
ack test.e; \
|
||||
a.out \
|
||||
: ok; \
|
||||
done
|
||||
rm -f test.e a.out
|
||||
>tested
|
||||
|
||||
last: tests test.h select
|
||||
echo 0 >last
|
||||
|
||||
select: select.c
|
||||
cc -O -n -o select select.c
|
||||
136
emtest/READ_ME
Normal file
136
emtest/READ_ME
Normal file
@@ -0,0 +1,136 @@
|
||||
This directory contains test programs for EM implementations.
|
||||
The test programs are all part of the file "tests".
|
||||
Each individual test program looks like:
|
||||
|
||||
TEST 004: test ...
|
||||
... ; data declarations etc.
|
||||
MAIN nlocal
|
||||
... ; part of the body of MAIN
|
||||
PROC
|
||||
... ; subroutines used by this test
|
||||
|
||||
The PROC part is optional, so the smallest test program looks like:
|
||||
|
||||
TEST 000: null test
|
||||
MAIN 0
|
||||
|
||||
The keywords used by "select", like TEST, MAIN, PROC, HOL, OK and ERRLAB,
|
||||
all consist of upper case letters and start in column one.
|
||||
A convention for test numbers is to use 3 digit numbers, possibly left
|
||||
padded with zero's.
|
||||
|
||||
A program, called "select", is provided to combine a range of tests
|
||||
into a single test program.
|
||||
"Select" expects a range as argument, like 0-127, or -127, or 0-.
|
||||
Tests that have a TEST number in that range are included.
|
||||
"Select" also expects the file from which the tests should
|
||||
be selected as an argument.
|
||||
If no argument is given, or only a range argument, select expects
|
||||
the tests to slect from on standard input.
|
||||
|
||||
To prevent name clashes, some rules must be obeyed:
|
||||
- data label names, procedure names and instruction label numbers
|
||||
must be unique over all tests. A good habit is to use the
|
||||
three digit test number as suffix.
|
||||
- only keyword of "select" may start with uppercase letters in column
|
||||
one, to allow for expansion in the future.
|
||||
- because only a single 'hol' pseudo is allowed, "select" must
|
||||
generate the 'hol' pseudo. An individual test may request
|
||||
some 'hol' space by a special HOL line, starting in column one
|
||||
and followed by a single number, the number of bytes needed.
|
||||
This number must consists of digits only, no constant symbols,
|
||||
because "select" must compute the maximum, so before the
|
||||
preprocessor has replaced the constant symbols by their values.
|
||||
- a similar problem is caused by the number of bytes of local
|
||||
storage for 'main'. An individual test may specify the number
|
||||
of bytes it needs as parameter to the MAIN line.
|
||||
Again, the number must consist of digits only.
|
||||
|
||||
Test programs print a sequence of integers greater than 1.
|
||||
This sequence is terminated by the number 1 as soon as an error is detected.
|
||||
If all tests are performed correctedly the number 0 is printed.
|
||||
|
||||
To allow test programs to print integers without the full machinery of
|
||||
conversion and i/o routines, the EM instruction 'nop' is used.
|
||||
Each time this instruction is executed, the current line number as
|
||||
maintained by the 'lin' instruction must be printed, followed by a
|
||||
newline, at least during debugging.
|
||||
|
||||
The following abbrevation may be used in test programs:
|
||||
|
||||
OK -> lin n
|
||||
nop
|
||||
|
||||
Numbers are automatically assigned in order of static appearance.
|
||||
As soon as an error is detected you must branch to label 1, by instructions
|
||||
like 'bra *1' and 'zne *1'.
|
||||
Label 1 is automatically provided in the main routine.
|
||||
If you jump to label 1 in a subroutine, then that subroutine must
|
||||
end with ERRLAB, like in:
|
||||
|
||||
PROC
|
||||
pro $test,0
|
||||
...
|
||||
bra *1
|
||||
...
|
||||
ret 0
|
||||
ERRLAB
|
||||
end
|
||||
|
||||
An option to "select" is to generate 'fil' instructions whenever a
|
||||
new test starts.
|
||||
This is useful if 'nop' prints the 'fil' string as well as the 'lin' number.
|
||||
This 'f' option is on by default, off if a '-f' flag is given.
|
||||
|
||||
The EM file generated by "select" includes "test.h".
|
||||
"test.h" may contain definitions of the following symbols:
|
||||
W2S: the size of double precision integers, if implemented.
|
||||
FS: the size of single precision floats, if implemented.
|
||||
F2S: the size of double precision floats, if implemented.
|
||||
The value of these symbols, if defined, must be the size of the object involved.
|
||||
|
||||
Two other symbols are used:
|
||||
EM_PSIZE: pointer size
|
||||
EM_WSIZE: word size
|
||||
The machine dependent translation program, like 8086 and vax2, give
|
||||
definitions of these symbols while calling the EM encode program.
|
||||
Because these size names occur quite often, they may be abbreviated:
|
||||
WS -> EM_WSIZE
|
||||
PS -> EM_PSIZE
|
||||
|
||||
Before running the tests in the file "tests", it is wise to test
|
||||
the necessary basic functions with some simple tests like
|
||||
|
||||
TEST 000: null
|
||||
MAIN 0
|
||||
and
|
||||
TEST 001: ok
|
||||
MAIN 0
|
||||
OK
|
||||
and
|
||||
TEST 998: error
|
||||
MAIN 0
|
||||
bra *1
|
||||
and
|
||||
TEST 999: test lni
|
||||
MAIN 0
|
||||
lin 1
|
||||
lni
|
||||
loe 0
|
||||
loc 2
|
||||
bne *1
|
||||
OK
|
||||
The first two of these are part of "tests" as well. The last two are
|
||||
not included in "tests" intensionally, because they would fail.
|
||||
The last tests fails because it references the ABS block which is
|
||||
inaccessable after an 'hol' pseudo.
|
||||
Proceed as follows for each of these basic tests:
|
||||
- make a file called 'basic' containing the test
|
||||
- run select:
|
||||
select basic >basic.e
|
||||
- compile by
|
||||
machine basic.e
|
||||
- and load and run
|
||||
|
||||
where machine should be replaced by the name of program
|
||||
used to compile EM programs for the current machine.
|
||||
1
emtest/last
Normal file
1
emtest/last
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
10
emtest/ok
Executable file
10
emtest/ok
Executable file
@@ -0,0 +1,10 @@
|
||||
trap "" 1 2
|
||||
|
||||
while read x
|
||||
do
|
||||
case $x in
|
||||
0) exit 0;;
|
||||
bad) exit 1;;
|
||||
esac
|
||||
done
|
||||
exit 1
|
||||
249
emtest/select.c
Normal file
249
emtest/select.c
Normal file
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define LINSIZ 100
|
||||
|
||||
int sigs[] = {
|
||||
SIGHUP,
|
||||
SIGINT,
|
||||
SIGQUIT,
|
||||
SIGTERM,
|
||||
0
|
||||
};
|
||||
|
||||
char *prog;
|
||||
char line[LINSIZ];
|
||||
int nlocals = 0;
|
||||
int nhol = 0;
|
||||
int nerrors = 0;
|
||||
int oknum = 2;
|
||||
int fflag = 1;
|
||||
int low = 0;
|
||||
int high = 999;
|
||||
|
||||
FILE *file1;
|
||||
FILE *file2;
|
||||
FILE *file3;
|
||||
char name1[] = "/usr/tmp/f1XXXXXX";
|
||||
char name2[] = "/usr/tmp/f2XXXXXX";
|
||||
char name3[] = "/usr/tmp/f3XXXXXX";
|
||||
|
||||
stop() {
|
||||
unlink(name1);
|
||||
unlink(name2);
|
||||
unlink(name3);
|
||||
exit(nerrors);
|
||||
}
|
||||
|
||||
main(argc,argv) char **argv; {
|
||||
register *p;
|
||||
register char *s;
|
||||
|
||||
prog = *argv++; --argc;
|
||||
mktemp(name1);
|
||||
mktemp(name2);
|
||||
mktemp(name3);
|
||||
for (p = sigs; *p; p++)
|
||||
if (signal(*p, stop) == SIG_IGN)
|
||||
signal(*p, SIG_IGN);
|
||||
while (argc > 0 && argv[0][0] == '-') {
|
||||
switch (argv[0][1]) {
|
||||
case 'f':
|
||||
fflag ^= 1;
|
||||
break;
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
high = atoi(&argv[0][1]);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc > 0 && argv[0][0] >= '0' && argv[0][0] <= '9') {
|
||||
s = argv[0];
|
||||
do
|
||||
low = low*10 + *s++ - '0';
|
||||
while (*s >= '0' && *s <= '9');
|
||||
if (*s == 0)
|
||||
high = low;
|
||||
else if (*s++ == '-') {
|
||||
high = atoi(s);
|
||||
if (high == 0)
|
||||
high = 999;
|
||||
} else
|
||||
fatal("bad range %s", argv[0]);
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc > 1)
|
||||
usage();
|
||||
if (argc == 1 && freopen(argv[0], "r", stdin) == NULL)
|
||||
fatal("cannot open %s", argv[0]);
|
||||
if ((file1 = fopen(name1, "w")) == NULL)
|
||||
fatal("cannot create %s", name1);
|
||||
if ((file2 = fopen(name2, "w")) == NULL)
|
||||
fatal("cannot create %s", name2);
|
||||
if ((file3 = fopen(name3, "w")) == NULL)
|
||||
fatal("cannot create %s", name3);
|
||||
if (getline())
|
||||
while (select())
|
||||
;
|
||||
fclose(file1);
|
||||
fclose(file2);
|
||||
fclose(file3);
|
||||
combine();
|
||||
stop();
|
||||
}
|
||||
|
||||
select() {
|
||||
register FILE *f;
|
||||
int i;
|
||||
|
||||
if (sscanf(line, "TEST %d", &i) != 1)
|
||||
fatal("bad test identification(%s)", line);
|
||||
if (i < low || i > high) {
|
||||
while (getline())
|
||||
if (line[0] == 'T')
|
||||
return(1);
|
||||
return(0);
|
||||
}
|
||||
fprintf(file2, "; %s\n", line);
|
||||
if (fflag) {
|
||||
fprintf(file1, ".%03d\n", i);
|
||||
fprintf(file1, " con \"tst%03d\"\n", i);
|
||||
fprintf(file2, " fil .%03d\n", i);
|
||||
}
|
||||
f = file1;
|
||||
while (getline()) {
|
||||
switch (line[0]) {
|
||||
case 'T':
|
||||
return(1);
|
||||
case 'M':
|
||||
if (sscanf(line, "MAIN%d", &i) != 1 || i%4 != 0)
|
||||
break;
|
||||
if (i > nlocals)
|
||||
nlocals = i;
|
||||
f = file2;
|
||||
continue;
|
||||
case 'P':
|
||||
if (strcmp(line, "PROC") != 0)
|
||||
break;
|
||||
f = file3;
|
||||
continue;
|
||||
case 'H':
|
||||
if (f != file1 ||
|
||||
sscanf(line, "HOL%d", &i) != 1 ||
|
||||
i%4 != 0)
|
||||
break;
|
||||
if (i > nhol)
|
||||
nhol = i;
|
||||
continue;
|
||||
case 'O':
|
||||
if (strcmp(line, "OK") != 0)
|
||||
break;
|
||||
fprintf(f, " lin %d\n nop\n", oknum++);
|
||||
continue;
|
||||
case 'E':
|
||||
if (f != file3 || strcmp(line, "ERRLAB") != 0)
|
||||
break;
|
||||
fprintf(f, "1\n lin 1\n nop\n loc 1\n loc 1\n mon\n");
|
||||
continue;
|
||||
default:
|
||||
putline(f);
|
||||
continue;
|
||||
}
|
||||
fatal("bad line (%s)", line);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
combine() {
|
||||
|
||||
printf("#define WS EM_WSIZE\n");
|
||||
printf("#define PS EM_PSIZE\n");
|
||||
printf("#include \"test.h\"\n");
|
||||
printf(" mes 2,WS,PS\n");
|
||||
printf(" mes 1\n");
|
||||
printf(" mes 4,300\n");
|
||||
if (nhol)
|
||||
printf(" hol %d,0,0\n", nhol);
|
||||
copy(name1);
|
||||
printf(" exp $m_a_i_n\n");
|
||||
printf(" pro $m_a_i_n,%d\n", nlocals);
|
||||
printf(" loc 123\n");
|
||||
printf(" loc -98\n");
|
||||
copy(name2);
|
||||
printf(" loc -98\n");
|
||||
printf(" bne *1\n");
|
||||
printf(" loc 123\n");
|
||||
printf(" bne *1\n");
|
||||
printf(" lin 0\n");
|
||||
printf(" nop\n");
|
||||
printf(" loc 0\n");
|
||||
printf(" ret WS\n");
|
||||
printf("1\n");
|
||||
printf(" lin 1\n");
|
||||
printf(" nop\n");
|
||||
printf(" loc 1\n");
|
||||
printf(" ret WS\n");
|
||||
printf(" end\n");
|
||||
copy(name3);
|
||||
}
|
||||
|
||||
copy(s) char *s; {
|
||||
if (freopen(s, "r", stdin) == NULL)
|
||||
fatal("cannot reopen %s", s);
|
||||
while (getline())
|
||||
putline(stdout);
|
||||
}
|
||||
|
||||
getline() {
|
||||
register len;
|
||||
|
||||
if (fgets(line, LINSIZ, stdin) == NULL)
|
||||
return(0);
|
||||
len = strlen(line);
|
||||
if (line[len-1] != '\n')
|
||||
fatal("line too long(%s)", line);
|
||||
line[len-1] = 0;
|
||||
return(1);
|
||||
}
|
||||
|
||||
putline(f) FILE *f; {
|
||||
fprintf(f, "%s\n", line);
|
||||
}
|
||||
|
||||
fatal(s, a1, a2, a3, a4) char *s; {
|
||||
fprintf(stderr, "%s: ", prog);
|
||||
fprintf(stderr, s, a1, a2, a3, a4);
|
||||
fprintf(stderr, " (fatal)\n");
|
||||
nerrors++;
|
||||
stop();
|
||||
}
|
||||
|
||||
usage() {
|
||||
fprintf(stderr, "usage: %s -f [[low]-[high]] [testcollection]\n", prog);
|
||||
nerrors++;
|
||||
stop();
|
||||
}
|
||||
28
emtest/test.e
Normal file
28
emtest/test.e
Normal file
@@ -0,0 +1,28 @@
|
||||
#define WS EM_WSIZE
|
||||
#define PS EM_PSIZE
|
||||
#include "test.h"
|
||||
mes 2,WS,PS
|
||||
mes 1
|
||||
mes 4,300
|
||||
.000
|
||||
con "tst000"
|
||||
exp $m_a_i_n
|
||||
pro $m_a_i_n,0
|
||||
loc 123
|
||||
loc -98
|
||||
; TEST 000: empty
|
||||
fil .000
|
||||
loc -98
|
||||
bne *1
|
||||
loc 123
|
||||
bne *1
|
||||
lin 0
|
||||
nop
|
||||
loc 0
|
||||
ret WS
|
||||
1
|
||||
lin 1
|
||||
nop
|
||||
loc 1
|
||||
ret WS
|
||||
end
|
||||
0
emtest/test.h
Normal file
0
emtest/test.h
Normal file
3605
emtest/tests
Normal file
3605
emtest/tests
Normal file
File diff suppressed because it is too large
Load Diff
26
etc/Makefile
Normal file
26
etc/Makefile
Normal file
@@ -0,0 +1,26 @@
|
||||
d=..
|
||||
h=$d/h
|
||||
c=$d/util/data
|
||||
|
||||
FILES= \
|
||||
$h/em_spec.h \
|
||||
$h/em_pseu.h \
|
||||
$h/em_mnem.h \
|
||||
$c/em_flag.c \
|
||||
$c/em_pseu.c \
|
||||
$c/em_mnem.c
|
||||
|
||||
$(FILES): em_table
|
||||
new_table $h $c
|
||||
|
||||
install: $(FILES)
|
||||
|
||||
opr:
|
||||
make pr ^ opr
|
||||
pr:
|
||||
@pr Makefile em_table new_table pop_push traps
|
||||
|
||||
clean:
|
||||
-rm -f *.old
|
||||
|
||||
cmp : # do nothing
|
||||
175
etc/em_table
Normal file
175
etc/em_table
Normal file
@@ -0,0 +1,175 @@
|
||||
magic 173
|
||||
fmnem 1
|
||||
nmnem 149
|
||||
fpseu 150
|
||||
npseu 30
|
||||
filb0 180
|
||||
nilb0 60
|
||||
fcst0 0
|
||||
zcst0 120
|
||||
ncst0 240
|
||||
fspec 240
|
||||
nspec 16
|
||||
ilb1 240
|
||||
ilb2 241
|
||||
dlb1 242
|
||||
dlb2 243
|
||||
dnam 244
|
||||
cst2 245
|
||||
cst4 246
|
||||
cst8 247
|
||||
doff 248
|
||||
pnam 249
|
||||
scon 250
|
||||
icon 251
|
||||
ucon 252
|
||||
fcon 253
|
||||
cend 255
|
||||
|
||||
bss 0
|
||||
con 1
|
||||
end 2
|
||||
exa 3
|
||||
exc 4
|
||||
exp 5
|
||||
hol 6
|
||||
ina 7
|
||||
inp 8
|
||||
mes 9
|
||||
pro 10
|
||||
rom 11
|
||||
|
||||
aar w- -p-a-p+p
|
||||
adf w- -a-a+a
|
||||
adi w- -a-a+a
|
||||
adp f- -p+p
|
||||
ads w- -a-p+p
|
||||
adu w- -a-a+a
|
||||
and w- -a-a+a
|
||||
asp f- -a
|
||||
ass w- -a-x
|
||||
beq bc -w-w
|
||||
bge bc -w-w
|
||||
bgt bc -w-w
|
||||
ble bc -w-w
|
||||
blm z- -p-p
|
||||
bls w- -a-p-p
|
||||
blt bc -w-w
|
||||
bne bc -w-w
|
||||
bra bt 0
|
||||
cai -p -p
|
||||
cal pp 0
|
||||
cff -- -w-w-y+x
|
||||
cfi -- -w-w-y+x
|
||||
cfu -- -w-w-y+x
|
||||
cif -- -w-w-y+x
|
||||
cii -- -w-w-y+x
|
||||
ciu -- -w-w-y+x
|
||||
cmf w- -a-a+w
|
||||
cmi w- -a-a+w
|
||||
cmp -- -p-p+w
|
||||
cms w- -a-a+w
|
||||
cmu w- -a-a+w
|
||||
com w- -a-a+a
|
||||
csa wt -p-a
|
||||
csb wt -p-a
|
||||
cuf -- -w-w-y+x
|
||||
cui -- -w-w-y+x
|
||||
cuu -- -w-w-y+x
|
||||
dch -- -p+p
|
||||
dec -- -w+w
|
||||
dee g- 0
|
||||
del l- 0
|
||||
dup s- -a+a+a
|
||||
dus w- -a-x+x+x
|
||||
dvf w- -a-a+a
|
||||
dvi w- -a-a+a
|
||||
dvu w- -a-a+a
|
||||
exg w- -a-a+a+a
|
||||
fef w- -a+a+w
|
||||
fif w- -a-a+a+a
|
||||
fil g- 0
|
||||
gto gt -p-?
|
||||
inc -- -w+w
|
||||
ine g- 0
|
||||
inl l- 0
|
||||
inn w- -w-a+w
|
||||
ior w- -a-a+a
|
||||
lae g- +p
|
||||
lal l- +p
|
||||
lar w- -p-a-p+?
|
||||
ldc d- +d
|
||||
lde g- +d
|
||||
ldf f- -p+d
|
||||
ldl l- +d
|
||||
lfr s- +a
|
||||
lil l- +w
|
||||
lim -- +w
|
||||
lin n- 0
|
||||
lni -- 0
|
||||
loc c- +w
|
||||
loe g- +w
|
||||
lof f- -p+w
|
||||
loi o- -p+a
|
||||
lol l- +w
|
||||
lor r- +p
|
||||
los w- -a-p+x
|
||||
lpb -- -p+p
|
||||
lpi p- +p
|
||||
lxa n- +p
|
||||
lxl n- +p
|
||||
mlf w- -a-a+a
|
||||
mli w- -a-a+a
|
||||
mlu w- -a-a+a
|
||||
mon -- -?+?
|
||||
ngf w- -a+a
|
||||
ngi w- -a+a
|
||||
nop -- 0
|
||||
rck w- -p-a+a
|
||||
ret zt -a-?
|
||||
rmi w- -a-a+a
|
||||
rmu w- -a-a+a
|
||||
rol w- -w-a+a
|
||||
ror w- -w-a+a
|
||||
rtt -t -?
|
||||
sar w- -p-a-p-?
|
||||
sbf w- -a-a+a
|
||||
sbi w- -a-a+a
|
||||
sbs w- -p-p+a
|
||||
sbu w- -a-a+a
|
||||
sde g- -d
|
||||
sdf f- -p-d
|
||||
sdl l- -d
|
||||
set w- -w+a
|
||||
sig -- -p-p+p+p
|
||||
sil l- -w
|
||||
sim -- -w
|
||||
sli w- -w-a+a
|
||||
slu w- -w-a+a
|
||||
sri w- -w-a+a
|
||||
sru w- -w-a+a
|
||||
ste g- -w
|
||||
stf f- -p-w
|
||||
sti o- -p-a
|
||||
stl l- -w
|
||||
str r- -p
|
||||
sts w- -a-p-x
|
||||
teq -- -w+w
|
||||
tge -- -w+w
|
||||
tgt -- -w+w
|
||||
tle -- -w+w
|
||||
tlt -- -w+w
|
||||
tne -- -w+w
|
||||
trp -p -w+?
|
||||
xor w- -a-a+a
|
||||
zeq bc -w
|
||||
zer w- +a
|
||||
zge bc -w
|
||||
zgt bc -w
|
||||
zle bc -w
|
||||
zlt bc -w
|
||||
zne bc -w
|
||||
zre g- 0
|
||||
zrf w- +a
|
||||
zrl l- 0
|
||||
|
||||
71
etc/new_table
Executable file
71
etc/new_table
Executable file
@@ -0,0 +1,71 @@
|
||||
h=${1-.}
|
||||
d=${2-.}
|
||||
|
||||
set `grep fpseu em_table`
|
||||
p=$2
|
||||
set `grep fmnem em_table`
|
||||
m=$2
|
||||
|
||||
ed - em_table <<'A' > X
|
||||
1,/^$/g/ /s// /gp
|
||||
A
|
||||
|
||||
ed - em_table <<'A' | awk '{print $1,$2+'$p'}' > Y
|
||||
1,/^$/d
|
||||
1,/^$/g/ /s// /gp
|
||||
A
|
||||
|
||||
ed - em_table <<'A' | awk '{print $0,'$m'+i++}' > Z
|
||||
1,/^$/d
|
||||
1,/^$/d
|
||||
1,/^$/g/ /s// /gp
|
||||
A
|
||||
|
||||
i=`wc -l <Y`
|
||||
echo 'lpseu' `expr $i + $p - 1` >>X
|
||||
i=`wc -l <Z`
|
||||
echo 'lmnem' `expr $i + $m - 1` >>X
|
||||
|
||||
ed - X <<'A' > $h/em_spec.h
|
||||
g/^/s//#define sp_/p
|
||||
A
|
||||
|
||||
ed - Y <<'A' > $h/em_pseu.h
|
||||
g/\(.*\) \(.*\)/s//#define ps_\1 \2/p
|
||||
A
|
||||
|
||||
ed - Z <<'A' > $h/em_mnem.h
|
||||
g/ .* /s// /
|
||||
g/\(.*\) \(.*\)/s//#define op_\1 \2/p
|
||||
A
|
||||
|
||||
(
|
||||
echo 'char em_pseu[][4] = {'
|
||||
ed - Y <<'A'
|
||||
g/\(...\).*/s// "\1",/p
|
||||
A
|
||||
echo '};'
|
||||
) > $d/em_pseu.c
|
||||
|
||||
(
|
||||
echo 'char em_mnem[][4] = {'
|
||||
ed - Z <<'A'
|
||||
g/\(...\).*/s// "\1",/p
|
||||
A
|
||||
echo '};'
|
||||
) > $d/em_mnem.c
|
||||
|
||||
(
|
||||
echo '#include <em_flag.h>
|
||||
char em_flag[] = {'
|
||||
ed - Z <<'A' | tr a-z A-Z
|
||||
g/^... /s///
|
||||
g/ .*/s///
|
||||
g/\(.\)\(.\)/s//PAR_\1 | FLO_\2/
|
||||
g/-/s//NO/g
|
||||
g/.*/s// &,/p
|
||||
A
|
||||
echo '};'
|
||||
) > $d/em_flag.c
|
||||
|
||||
rm X Y Z
|
||||
289
etc/pc_errors
Normal file
289
etc/pc_errors
Normal file
@@ -0,0 +1,289 @@
|
||||
non-standard feature used
|
||||
identifier '%s' declared twice
|
||||
end of file encountered
|
||||
bad line directive
|
||||
unsigned real: digit of fraction expected
|
||||
unsigned real: digit of exponent expected
|
||||
unsigned real: too many digits (>72)
|
||||
unsigned integer: too many digits (>72)
|
||||
unsigned integer: overflow (>32767)
|
||||
string constant: must not exceed one line
|
||||
string constant: at least one character expected
|
||||
string constant: double quotes not allowed (see c option)
|
||||
string constant: too long (>72 chars)
|
||||
bad character
|
||||
identifier '%s' not declared
|
||||
location counter overflow: arrays too big
|
||||
location counter overflow: arrays too big
|
||||
arraysize too big
|
||||
variable '%s' never used
|
||||
variable '%s' never assigned
|
||||
the files contained in '%s' are not closed automatically
|
||||
constant expected
|
||||
constant: only integers and reals may be signed
|
||||
constant: out of bounds
|
||||
simple type expected
|
||||
enumerated type: element identifier expected
|
||||
enumerated type: ',' or ')' expected
|
||||
enumerated type: ',' expected
|
||||
enumerated type: ')' expected
|
||||
subrange type: type must be scalar, but not real
|
||||
subrange type: '..' expected
|
||||
subrange type: type of lower and upper bound incompatible
|
||||
subrange type: lower bound exceeds upper bound
|
||||
array type: '[' expected
|
||||
conformant array: low bound identifier expected
|
||||
conformant array: '..' expected
|
||||
conformant array: high bound identifier expected
|
||||
conformant array: ':' expected
|
||||
conformant array: index type identifier expected
|
||||
array type: index type not bounded
|
||||
array type: index separator or ']' expected
|
||||
array type: index separator expected
|
||||
array type: ']' expected
|
||||
array type: 'of' expected
|
||||
record variant part: tag type identifier expected
|
||||
record variant part: tag type identifier expected
|
||||
record variant part: type must be bounded
|
||||
record variant part: 'of' expected
|
||||
record variant: type of case label and tag incompatible
|
||||
record variant: multiple defined case label
|
||||
record variant: ',' or ':' expected
|
||||
record variant: ',' expected
|
||||
record variant: ':' expected
|
||||
record variant: '(' expected
|
||||
record variant: ')' expected
|
||||
record variant part: ';' or end of variant list expected
|
||||
record variant part: ';' expected
|
||||
record variant part: end of variant list expected
|
||||
record variant part: there must be a variant for each tag value
|
||||
field list: record section expected
|
||||
record section: field identifier expected
|
||||
record section: ',' or ':' expected
|
||||
record section: ',' expected
|
||||
record section: ':' expected
|
||||
field list: ';' or end of record section list expected
|
||||
field list: ';' expected
|
||||
field list: end of record section list expected
|
||||
type expected
|
||||
type: simple and pointer type may not be packed
|
||||
pointer type: type identifier expected
|
||||
pointer type: type identifier expected
|
||||
record type: 'end' expected
|
||||
set type: 'of' expected
|
||||
set type: too many elements in set
|
||||
set type: bad subrange of integer
|
||||
set of integer: the i option dictates the number of bits (default 16)
|
||||
set type: base type not bounded
|
||||
file type: 'of' expected
|
||||
file type: files within files not allowed
|
||||
var parameter: type identifier or conformant array expected
|
||||
var parameter: type identifier expected
|
||||
label declaration: unsigned integer expected
|
||||
label declaration: label '%i' multiple declared
|
||||
label declaration: ',' or ';' expected
|
||||
label declaration: ',' expected
|
||||
label declaration: ';' expected
|
||||
const declaration: constant identifier expected
|
||||
const declaration: '=' expected
|
||||
const declaration: ';' expected
|
||||
const declaration: constant identifier or 'type', 'var', 'procedure', 'function' or 'begin' expected
|
||||
type declaration: type identifier expected
|
||||
type declaration: '=' expected
|
||||
type declaration: ';' expected
|
||||
type declaration: type identifier or 'var', 'procedure', 'function' or 'begin' expected
|
||||
var declaration: var identifier expected
|
||||
var declaration: ',' or ':' expected
|
||||
var declaration: ',' expected
|
||||
var declaration: ':' expected
|
||||
var declaration: ';' expected
|
||||
var declaration: var identifier or 'procedure', 'function' or 'begin' expected
|
||||
parameter list: 'var','procedure','function' or identifier expected
|
||||
parameter list: parameter identifier expected
|
||||
parameter list: ',' or ':' expected
|
||||
parameter list: ',' expected
|
||||
parameter list: ':' expected
|
||||
parameter list: type identifier expected
|
||||
parameter list: ';' or ')' expected
|
||||
parameter list: ';' expected
|
||||
proc/func declaration: proc/func identifier expected
|
||||
proc/func declaration: previous declaration of '%s' was not forward
|
||||
proc/func declaration: parameter list expected
|
||||
parameterlist: ')' expected
|
||||
func declaration: ':' expected
|
||||
func declaration: result type identifier expected
|
||||
func declaration: result type must be scalar, subrange or pointer
|
||||
proc/func declaration: ';' expected
|
||||
proc/func declaration: block or directive expected
|
||||
proc/func declaration: '%s' unknown directive
|
||||
proc/func declaration: '%s' again forward declared
|
||||
proc/func declaration: ';' expected
|
||||
indexed variable: '[' only allowed following array variables
|
||||
indexed variable: index type not compatible with declaration
|
||||
indexed variable: ',' or ']' expected
|
||||
indexed variable: ',' expected
|
||||
assignment: standard function not allowed as destination
|
||||
assignment: cannot store the function result
|
||||
assignment: formal parameter function not allowed as destination
|
||||
assignment: function identifier may not be de-referenced
|
||||
variable: '[', '.', '^' or end of variable expected
|
||||
indexed variable: ']' expected
|
||||
field designator: field identifier expected
|
||||
field designator: '.' only allowed following record variables
|
||||
field designator: no field '%s' in this record
|
||||
referenced variable: '^' not allowed following zero-terminated strings
|
||||
referenced variable: '^' only allowed following pointer or file variables
|
||||
variable: var or field identifier expected
|
||||
call: too many actual parameters supplied
|
||||
call: proc/func identifier expected
|
||||
call: standard proc/func may not be used as parameter
|
||||
call: parameter lists of actual and formal proc/func incompatible
|
||||
call: type of actual and formal value parameter not compatible
|
||||
call: array parameter not conformable
|
||||
call: type of actual and formal variable parameter not similar
|
||||
call: packed elements not allowed as variable parameter
|
||||
call: ',' or ')' expected
|
||||
call: too few actual parameters supplied
|
||||
read(ln): type must be integer, char or real
|
||||
write(ln): type must be integer, char, real, string or boolean
|
||||
write(ln): ':', ',' or ')' expected
|
||||
write(ln): field width must be integer
|
||||
write(ln): ':', ',' or ')' expected
|
||||
write(ln): precision must be integer
|
||||
write(ln): precision may only be specified for reals
|
||||
read/write: too few actual parameters supplied
|
||||
read/write: standard input/output not mentioned in program heading
|
||||
read/write: ',' or ')' expected
|
||||
read/write: type of parameter not the same as that of the file elements
|
||||
read/write: parameter list expected
|
||||
readln/writeln: standard input/output not mentioned in program heading
|
||||
readln/writeln: only allowed on text files
|
||||
new/dispose: C-type strings not allowed here
|
||||
new/dispose: ',' or ')' expected
|
||||
new/dispose: too many actual parameters supplied
|
||||
new/dispose: type of tagfield value is incompatible with declaration
|
||||
call: '(' or end of call expected
|
||||
standard proc/func: parameter list expected
|
||||
standard input/output not mentioned in program heading
|
||||
file variable expected
|
||||
pointer variable expected
|
||||
pack: ',' expected
|
||||
pack: ',' expected
|
||||
unpack: ',' expected
|
||||
unpack: ',' expected
|
||||
standard proc/func: parameter type incompatible with specification
|
||||
eoln/page: text file variable expected
|
||||
pack/unpack: array types are incompatible
|
||||
pack/unpack: only for arrays
|
||||
abs: integer or real expected
|
||||
sqr: integer or real expected
|
||||
ord: type must be scalar or subrange, but not real
|
||||
pred/succ: type must be scalar or subrange, but not real
|
||||
trunc/round: real argument required
|
||||
call: ')' expected
|
||||
expression: left and right operand are incompatible
|
||||
set: incompatible elements
|
||||
set: base type must be bounded or of type integer
|
||||
set: base type upper bound exceeds maximum set element number
|
||||
set: element out of range
|
||||
set: ']' or element list expected
|
||||
set: '..', ',' or ']' expected
|
||||
set: ',' or ']' expected
|
||||
set: ',' expected
|
||||
factor expected
|
||||
factor: ')' expected
|
||||
factor: type of factor must be boolean
|
||||
set: ']' expected
|
||||
term: multiplying operator or end of term expected
|
||||
term: '*' only defined for integers, reals and sets
|
||||
term: '/' only defined for integers and reals
|
||||
term: 'div' only defined for integers
|
||||
term: 'mod' only defined for integers
|
||||
term: 'and' only defined for booleans
|
||||
simple expression: only integers and reals may be signed
|
||||
simple expression: adding operator or end of simple expression expected
|
||||
simple expression: '+' only defined for integers, reals and sets
|
||||
simple expression: '-' only defined for integers, reals and sets
|
||||
simple expression: 'or' only defined for booleans
|
||||
expression: relational operator or end of expression expected
|
||||
expression: set expected
|
||||
expression: left operand of 'in' not compatible with base type of right operand
|
||||
expression: only '=' and '<>' allowed on pointers
|
||||
expression: '<' and '>' not allowed on sets
|
||||
expression: comparison of arrays only allowed for strings
|
||||
expression: comparison of records not allowed
|
||||
expression: comparison of files not allowed
|
||||
assignment: ':=' expected
|
||||
assignment: left and right hand side incompatible
|
||||
goto statement: unsigned integer expected
|
||||
goto statement: label '%i' not declared
|
||||
if statement: type of expression must be boolean
|
||||
if statement: 'then' expected
|
||||
if statement: 'else' or end of if statement expected
|
||||
case statement: type must be scalar or subrange, but not real
|
||||
case statement: 'of' expected
|
||||
case statement: incompatible case label
|
||||
case statement: multiple defined case label
|
||||
case statement: ',' or ':' expected
|
||||
case statement: ',' expected
|
||||
case statement: ':' expected
|
||||
case statement: ';' or 'end' expected
|
||||
case statement: ';' expected
|
||||
case statement: 'end' expected
|
||||
repeat statement: ';' or 'until' expected
|
||||
repeat statement: ';' expected
|
||||
repeat statement: 'until' expected
|
||||
repeat statement: type of expression must be boolean
|
||||
while statement: type of expression must be boolean
|
||||
while statement: 'do' expected
|
||||
for statement: type of bound and control variable incompatible
|
||||
for statement: control variable expected
|
||||
for statement: control variable must be local
|
||||
for statement: type must be scalar or subrange, but not real
|
||||
for statement: ':=' expected
|
||||
for statement: 'to' or 'downto' expected
|
||||
for statement: upper bound not assignment compatible
|
||||
for statement: 'do' expected
|
||||
with statement: record variable expected
|
||||
with statement: ',' or 'do' expected
|
||||
with statement: ',' expected
|
||||
with statement: 'do' expected
|
||||
assertion: type of expression must be boolean
|
||||
statement expected
|
||||
label '%i' not declared
|
||||
label '%i' multiple defined
|
||||
statement: ':' expected
|
||||
unlabeled statement expected
|
||||
compound statement: ';' or 'end' expected
|
||||
compound statement: ';' expected
|
||||
compound statement: 'end' expected
|
||||
case statement: 'end' expected
|
||||
body: ';' or 'end' expected
|
||||
body: ';' expected
|
||||
body: label '%i' declared, but never defined
|
||||
program parameter '%s' not declared
|
||||
function '%s' never assigned
|
||||
block: declaration or body expected
|
||||
block: 'const', 'type', 'var', 'procedure', 'function' or 'begin' expected
|
||||
block: 'type', 'var', 'procedure', 'function' or 'begin' expected
|
||||
block: 'var', 'procedure', 'function' or 'begin' expected
|
||||
block: 'procedure', 'function' or 'begin' expected
|
||||
block: unsatisfied forward proc/func declaration(s)
|
||||
block: 'begin' expected
|
||||
block: 'end' expected
|
||||
program heading: 'program' expected
|
||||
program heading: program identifier expected
|
||||
program heading: file identifier list expected
|
||||
program heading: file identifier expected
|
||||
program heading: ',' or ')' expected
|
||||
program heading: ',' expected
|
||||
program heading: maximum number of file arguments exceeded (12)
|
||||
program heading: ')' expected
|
||||
program heading: ';' expected
|
||||
program: '.' expected
|
||||
'program' expected
|
||||
module: 'const', 'type', 'var', 'procedure' or 'function' expected
|
||||
module: 'type', 'var', 'procedure' or 'function' expected
|
||||
module: 'var', 'procedure' or 'function' expected
|
||||
module: 'procedure' or 'function' expected
|
||||
garbage at end of program
|
||||
107
etc/pc_rt_errors
Normal file
107
etc/pc_rt_errors
Normal file
@@ -0,0 +1,107 @@
|
||||
array bound error
|
||||
range bound error
|
||||
set bound error
|
||||
integer overflow
|
||||
real overflow
|
||||
real underflow
|
||||
divide by 0
|
||||
divide by 0.0
|
||||
undefined integer
|
||||
real undefined
|
||||
conversion error
|
||||
error 11
|
||||
error 12
|
||||
error 13
|
||||
error 14
|
||||
error 15
|
||||
stack overflow
|
||||
heap error
|
||||
illegal instruction
|
||||
odd or zero byte count
|
||||
case error
|
||||
memory fault
|
||||
bad pointer
|
||||
bad program counter
|
||||
bad external address
|
||||
bad monitor call
|
||||
bad line number
|
||||
error 27
|
||||
error 28
|
||||
error 29
|
||||
error 30
|
||||
error 31
|
||||
error 32
|
||||
error 33
|
||||
error 34
|
||||
error 35
|
||||
error 36
|
||||
error 37
|
||||
error 38
|
||||
error 39
|
||||
error 40
|
||||
error 41
|
||||
error 42
|
||||
error 43
|
||||
error 44
|
||||
error 45
|
||||
error 46
|
||||
error 47
|
||||
error 48
|
||||
error 49
|
||||
error 50
|
||||
error 51
|
||||
error 52
|
||||
error 53
|
||||
error 54
|
||||
error 55
|
||||
error 56
|
||||
error 57
|
||||
error 58
|
||||
error 59
|
||||
error 60
|
||||
error 61
|
||||
error 62
|
||||
error 63
|
||||
more args expected
|
||||
error in exp
|
||||
error in ln
|
||||
error in sqrt
|
||||
assertion failed
|
||||
array bound error in pack
|
||||
array bound error in unpack
|
||||
only positive j in 'i mod j'
|
||||
file not yet open
|
||||
dispose error
|
||||
error 74
|
||||
error 75
|
||||
error 76
|
||||
error 77
|
||||
error 78
|
||||
error 79
|
||||
error 80
|
||||
error 81
|
||||
error 82
|
||||
error 83
|
||||
error 84
|
||||
error 85
|
||||
error 86
|
||||
error 87
|
||||
error 88
|
||||
error 89
|
||||
error 90
|
||||
error 91
|
||||
error 92
|
||||
error 93
|
||||
error 94
|
||||
error 95
|
||||
not writable
|
||||
not readable
|
||||
end of file
|
||||
truncated
|
||||
reset error
|
||||
rewrite error
|
||||
close error
|
||||
read error
|
||||
write error
|
||||
digit expected
|
||||
non-ASCII char read
|
||||
15
etc/pop_push
Normal file
15
etc/pop_push
Normal file
@@ -0,0 +1,15 @@
|
||||
description of third column of em_table:
|
||||
|
||||
-: pop item indicated by next character
|
||||
+: push item indicated by next character
|
||||
0: no effect on the stack
|
||||
|
||||
characters describing items:
|
||||
|
||||
w: target machine word (1, 2 or 4)
|
||||
d: double target machine word (2, 4 or 8)
|
||||
p: target machine address
|
||||
a: item with size specified in argument
|
||||
x: item with size specified by top item of stack
|
||||
y: item with size specified by second item on stack
|
||||
?: one or more items of unknown size
|
||||
28
etc/traps
Normal file
28
etc/traps
Normal file
@@ -0,0 +1,28 @@
|
||||
~ Array bound error
|
||||
~ Range bound error
|
||||
~ Set bound error
|
||||
~ Integer overflow
|
||||
~ Floating overflow
|
||||
~ Floating underflow
|
||||
~ Divide by 0
|
||||
~ Divide by 0.0
|
||||
~ Integer undefined
|
||||
~ Floating undefined
|
||||
~ Conversion error
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
* Stack overflow
|
||||
* Heap overflow
|
||||
* Illegal instruction
|
||||
* Illegal odd or zero argument
|
||||
* Case error
|
||||
* Addressing non existent memory
|
||||
* Bad pointer used
|
||||
* Program counter out of range
|
||||
* Bad argument of LAE
|
||||
* Bad monitor call
|
||||
* Argument of LIN too high
|
||||
* Bad GTO descriptor
|
||||
32
first/ckpath
Normal file
32
first/ckpath
Normal file
@@ -0,0 +1,32 @@
|
||||
rm -f ../bin/x_tpath x_tpath
|
||||
echo "echo $$" >../bin/x_tpath
|
||||
rm -f x_tpath
|
||||
chmod +x ../bin/x_tpath
|
||||
case x`(x_tpath) 2>/dev/null`
|
||||
in
|
||||
x$$)
|
||||
STAT=0 ;;
|
||||
x)
|
||||
(cd ../bin ; echo Sorry, `pwd` is not in your shell PATH" ($PATH)")
|
||||
STAT=1 ;;
|
||||
*)
|
||||
echo "Sorry, there is something wrong with your PATH ($PATH)" ;;
|
||||
esac
|
||||
echo "echo l_$$" >x_tpath
|
||||
chmod +x x_tpath
|
||||
case x`(x_tpath) 2>/dev/null`
|
||||
in
|
||||
xl_$$)
|
||||
;;
|
||||
x)
|
||||
(cd ../bin ; echo Sorry, . is not in your shell PATH" ($PATH)")
|
||||
STAT=2 ;;
|
||||
x$$)
|
||||
echo Sorry, . is not in your PATH" ($PATH)" or after the ACK bin directory
|
||||
STAT=3 ;;
|
||||
*)
|
||||
echo "Sorry, there is something wrong with your PATH ($PATH)"
|
||||
STAT=4 ;;
|
||||
esac
|
||||
rm -f ../bin/x_tpath x_tpath
|
||||
exit $STAT
|
||||
7
first/did_first
Executable file
7
first/did_first
Executable file
@@ -0,0 +1,7 @@
|
||||
if (ack_sys ) >/dev/null 2>&1
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
echo "You need to run 'first' first"
|
||||
exit 1
|
||||
fi
|
||||
@@ -4,4 +4,4 @@
|
||||
/* Access to the ACK tree and parts thereof */
|
||||
#define EM_DIR "/usr/em" /* The root directory for EM stuff */
|
||||
#define RTERR_PATH "etc/pc_rt_errors"
|
||||
#define ACK_PATH "lib/ack"
|
||||
#define ACK_PATH "lib/descr"
|
||||
|
||||
146
first/first
Executable file
146
first/first
Executable file
@@ -0,0 +1,146 @@
|
||||
: check $PATH first
|
||||
if sh ckpath
|
||||
then :
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
: check write-ability of /tmp and /usr/tmp
|
||||
if ( >/usr/tmp/aaax.$$ )
|
||||
then
|
||||
rm /usr/tmp/aaax.$$
|
||||
else
|
||||
echo /usr/tmp must exist and be writable.
|
||||
exit 2
|
||||
fi
|
||||
if ( >/tmp/aaax.$$ )
|
||||
then
|
||||
rm /tmp/aaax.$$
|
||||
else
|
||||
echo /tmp must exist and be writable.
|
||||
exit 2
|
||||
fi
|
||||
: set ACK HOME Directory in ../h/em_path.h
|
||||
rm -f em_path.h
|
||||
sed -e "/^#define[ ]*EM_DIR/s@\".*\"@\"`cd .. ; pwd`\"@" <../h/em_path.h >em_path.h
|
||||
if cmp ../h/em_path.h em_path.h >/dev/null 2>&1
|
||||
then
|
||||
: Don't touch ../h/em_path.h, it's already correct
|
||||
else
|
||||
rm -f ../h/em_path.h
|
||||
if mv em_path.h ../h >/dev/null 2>&1
|
||||
then : success
|
||||
else
|
||||
echo "Sorry, can't replace ../h/em_path.h"
|
||||
exit 7
|
||||
fi
|
||||
fi
|
||||
: remove non-system as and ld from descr files
|
||||
if (ack_sys) >/dev/null 2>&1
|
||||
then
|
||||
: echo Your system is: `ack_sys`.
|
||||
else
|
||||
echo -n "Give me the type of your system, the current choice is:
|
||||
pdp_v7 PDP11 with sep I/D and version 7
|
||||
vax_bsd4_1a VAX11 with BSD4.1a
|
||||
vax_bsd4_1c VAX11 with BSD4.1c
|
||||
vax_bsd4_2 VAX11 with BSD4.2
|
||||
pc_ix IBM PC with PC/IX
|
||||
m68_unisoft Motorola 68000 with Unisoft UNIX
|
||||
ANY Neither of the above
|
||||
|
||||
system type: "
|
||||
if read SYSNAME
|
||||
then
|
||||
echo echo "$SYSNAME" >../bin/ack_sys
|
||||
chmod +x ../bin/ack_sys
|
||||
case `ack_sys` in
|
||||
pdp_v7|vax_bsd4_1[ac]|vax_bsd4_2|pc_ix|m68_unisoft) ;;
|
||||
*) echo None of the software especially intended for the named systems will work ;;
|
||||
esac
|
||||
else
|
||||
echo Sorry, got EOF when reading system name.
|
||||
exit 8
|
||||
fi
|
||||
fi
|
||||
echo -n "Your system is `ack_sys`, are you satisfied with that? (y/n) "
|
||||
if read YESNO
|
||||
then
|
||||
case $YESNO in
|
||||
j*|y*) ;;
|
||||
n*) echo Ok, I will give you another chance....
|
||||
rm -f ../bin/ack_sys
|
||||
exec sh $0
|
||||
;;
|
||||
*) echo "I do not understand your answer ($YESNO). Bye"
|
||||
exit 9
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo Sorry, got EOF when reading your answer.
|
||||
exit 9
|
||||
fi
|
||||
: "Take action according to the system used"
|
||||
: 'Prevent the use of the system assembler on for certain systems'
|
||||
case `ack_sys` in
|
||||
vax_bsd*) RMD=pdp ;;
|
||||
pdp_*) RMD="vax2 vax4" ;;
|
||||
*) RMD="pdp vax2 vax4" ;;
|
||||
esac
|
||||
for i in $RMD
|
||||
do
|
||||
( cd ../lib/$i
|
||||
if grep '^name as$' descr >/dev/null 2>&1
|
||||
then
|
||||
cp descr descr.orig
|
||||
ed - descr <<'ABC'
|
||||
/^name as$/;/^end$/d
|
||||
/^name ld$/;/^end$/d
|
||||
w
|
||||
q
|
||||
ABC
|
||||
fi
|
||||
)
|
||||
done
|
||||
: 'Set the default machine in ../h/local.h'
|
||||
case `ack_sys` in
|
||||
pdp_v7) ACM=pdp ;;
|
||||
vax_bsd4_1[ac]) ACM=vax2 ;;
|
||||
vax_bsd4_2) ACM=vax2 ;;
|
||||
pc_ix) ACM=ix ;;
|
||||
m68_unisoft) ACM=m68k2 ;;
|
||||
*) ACM=m68k2 ;;
|
||||
esac
|
||||
rm -f local.h
|
||||
sed /ACKM/s/'".*"'/'"'$ACM'"'/ <../h/local.h >local.h
|
||||
if cmp -s ../h/local.h local.h
|
||||
then :
|
||||
else
|
||||
cp local.h ../h
|
||||
rm -f local.h
|
||||
fi
|
||||
echo "Your default machine to compile for is $ACM"
|
||||
case `ack_sys` in
|
||||
vax_bsd4_*)
|
||||
echo 'Installing the include directory in lib/vax2'
|
||||
( cd ../lib/vax2 ; sh fetch_inc )
|
||||
echo Done
|
||||
case `ack_sys` in
|
||||
vax_bsd4_1a) VERS=BSD41a ;;
|
||||
vax_bsd4_1c) VERS=BSD41c ;;
|
||||
vax_bsd4_2) VERS=BSD42 ;;
|
||||
*) echo "Unknown VAX BSD version, look at mach/vax[24]/libem"
|
||||
break ;;
|
||||
esac
|
||||
for i in vax2 vax4
|
||||
do (
|
||||
cd ../mach/$i/libem
|
||||
ed - system.h <<ABC
|
||||
g/^#/s/.*/\/* & *\//
|
||||
/$VERS/s/^.*#/#/
|
||||
/$VERS/s/*\/.*$//
|
||||
w
|
||||
q
|
||||
ABC
|
||||
) done
|
||||
echo 'mach/vax[24]/libem/system.h reflects your BSD version.'
|
||||
esac
|
||||
@@ -4,4 +4,4 @@
|
||||
# define VERSION 3 /* 16 bits number */
|
||||
|
||||
/* The default machine used by ack, acc, apc */
|
||||
# define ACKM "vax2"
|
||||
# define ACKM "pdp"
|
||||
|
||||
@@ -12,4 +12,6 @@ typedef struct{
|
||||
int strlength;
|
||||
} String;
|
||||
|
||||
String *_newstr() ;
|
||||
|
||||
#define MAXSTRING 1024
|
||||
|
||||
154
h/cgg_cg.h
Normal file
154
h/cgg_cg.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/* $Header$ */
|
||||
|
||||
/* offsets of interesting fields in EM-pattern */
|
||||
|
||||
#define PO_HASH 0
|
||||
#define PO_NEXT 1
|
||||
#define PO_MATCH 3
|
||||
|
||||
#define ILLHASH 0177777
|
||||
|
||||
|
||||
/* Commands for codegenerator, in low order 5 bits of byte */
|
||||
|
||||
#define DO_NEXTEM 0
|
||||
#define DO_MATCH 1
|
||||
#define DO_XMATCH 2
|
||||
#define DO_XXMATCH 3
|
||||
#define DO_REMOVE 4
|
||||
#define DO_DEALLOCATE 5
|
||||
#define DO_REALLOCATE 6
|
||||
#define DO_ALLOCATE 7
|
||||
#define DO_MOVE 10
|
||||
#define DO_ERASE 11
|
||||
#define DO_TOKREPLACE 12
|
||||
#define DO_EMREPLACE 13
|
||||
#define DO_COST 14
|
||||
#define DO_RETURN 15
|
||||
#define DO_COERC 16
|
||||
#define DO_PRETURN 17
|
||||
#define DO_RREMOVE 18
|
||||
#define DO_INSTR 19
|
||||
#define DO_TEST 20
|
||||
#define DO_DLINE 21
|
||||
#define DO_SETCC 22
|
||||
|
||||
#ifndef MAXATT
|
||||
#define MAXATT TOKENSIZE
|
||||
#endif
|
||||
|
||||
typedef struct instance {
|
||||
short in_which;
|
||||
# define IN_COPY 1
|
||||
# define IN_MEMB 2
|
||||
# define IN_RIDENT 3
|
||||
# define IN_ALLOC 4
|
||||
# define IN_DESCR 5
|
||||
# define IN_S_DESCR 6
|
||||
# define IN_D_DESCR 7
|
||||
short in_info[MAXATT+1];
|
||||
} inst_t,*inst_p;
|
||||
|
||||
typedef struct set {
|
||||
short set_size;
|
||||
short set_val[SETSIZE];
|
||||
} set_t,*set_p;
|
||||
|
||||
typedef struct {
|
||||
short m_set1; /* number of tokenexpr in move: from */
|
||||
short m_expr1; /* optional expression */
|
||||
short m_set2; /* number of tokenexpr in move: to */
|
||||
short m_expr2; /* optional expression */
|
||||
short m_cindex; /* code index to really do it */
|
||||
} move_t, *move_p;
|
||||
|
||||
typedef struct {
|
||||
short t_set; /* number of tokenexpr in test */
|
||||
short t_expr; /* optional expression */
|
||||
short t_cindex; /* code index to really do it */
|
||||
} test_t, *test_p;
|
||||
|
||||
struct exprnode {
|
||||
short ex_operator;
|
||||
short ex_lnode;
|
||||
short ex_rnode;
|
||||
};
|
||||
typedef struct exprnode node_t;
|
||||
typedef struct exprnode *node_p;
|
||||
|
||||
/*
|
||||
* contents of .ex_operator
|
||||
*/
|
||||
|
||||
#define EX_TOKFIELD 0
|
||||
#define EX_ARG 1
|
||||
#define EX_CON 2
|
||||
#define EX_ALLREG 3
|
||||
#define EX_SAMESIGN 4
|
||||
#define EX_SFIT 5
|
||||
#define EX_UFIT 6
|
||||
#define EX_ROM 7
|
||||
#define EX_NCPEQ 8
|
||||
#define EX_SCPEQ 9
|
||||
#define EX_RCPEQ 10
|
||||
#define EX_NCPNE 11
|
||||
#define EX_SCPNE 12
|
||||
#define EX_RCPNE 13
|
||||
#define EX_NCPGT 14
|
||||
#define EX_NCPGE 15
|
||||
#define EX_NCPLT 16
|
||||
#define EX_NCPLE 17
|
||||
#define EX_OR2 18
|
||||
#define EX_AND2 19
|
||||
#define EX_PLUS 20
|
||||
#define EX_CAT 21
|
||||
#define EX_MINUS 22
|
||||
#define EX_TIMES 23
|
||||
#define EX_DIVIDE 24
|
||||
#define EX_MOD 25
|
||||
#define EX_LSHIFT 26
|
||||
#define EX_RSHIFT 27
|
||||
#define EX_NOT 28
|
||||
#define EX_COMP 29
|
||||
#define EX_STRING 31
|
||||
#define EX_DEFINED 32
|
||||
#define EX_SUBREG 33
|
||||
#define EX_TOSTRING 34
|
||||
#define EX_UMINUS 35
|
||||
#define EX_REG 36
|
||||
#define EX_LOWW 37
|
||||
#define EX_HIGHW 38
|
||||
#define EX_INREG 39
|
||||
#define EX_REGVAR 40
|
||||
|
||||
|
||||
typedef struct { /* to stack coercions */
|
||||
short c1_texpno; /* token expression number */
|
||||
short c1_expr; /* boolean expression */
|
||||
short c1_prop; /* property of register needed */
|
||||
short c1_codep; /* code index */
|
||||
} c1_t,*c1_p;
|
||||
|
||||
#ifdef MAXSPLIT
|
||||
typedef struct { /* splitting coercions */
|
||||
short c2_texpno; /* token expression number */
|
||||
short c2_expr; /* optional boolean expression */
|
||||
short c2_nsplit; /* split factor */
|
||||
short c2_repl[MAXSPLIT];/* replacement instances */
|
||||
short c2_codep; /* code index */
|
||||
} c2_t,*c2_p;
|
||||
#endif MAXSPLIT
|
||||
|
||||
typedef struct { /* one to one coercions */
|
||||
short c3_texpno; /* token expression number */
|
||||
short c3_expr; /* boolean expression */
|
||||
short c3_prop; /* property of register needed */
|
||||
short c3_repl; /* replacement instance */
|
||||
short c3_codep; /* code index */
|
||||
} c3_t,*c3_p;
|
||||
|
||||
|
||||
#define getint(a,b) \
|
||||
if ((a=((*(b)++)&BMASK)) >= 128) {\
|
||||
a = ((a-128)<<BSHIFT) | (*(b)++&BMASK); \
|
||||
}
|
||||
21
include/_tail_mon/signal.h
Normal file
21
include/_tail_mon/signal.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#define NSIG 17
|
||||
|
||||
#define SIGHUP 1 /* hangup */
|
||||
#define SIGINT 2 /* interrupt */
|
||||
#define SIGQUIT 3 /* quit */
|
||||
#define SIGILL 4 /* illegal instruction (not reset when caught) */
|
||||
#define SIGTRAP 5 /* trace trap (not reset when caught) */
|
||||
#define SIGIOT 6 /* IOT instruction */
|
||||
#define SIGEMT 7 /* EMT instruction */
|
||||
#define SIGFPE 8 /* floating point exception */
|
||||
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
|
||||
#define SIGBUS 10 /* bus error */
|
||||
#define SIGSEGV 11 /* segmentation violation */
|
||||
#define SIGSYS 12 /* bad argument to system call */
|
||||
#define SIGPIPE 13 /* write on a pipe with no one to read it */
|
||||
#define SIGALRM 14 /* alarm clock */
|
||||
#define SIGTERM 15 /* software termination signal from kill */
|
||||
|
||||
int (*signal())();
|
||||
#define SIG_DFL (int (*)())0
|
||||
#define SIG_IGN (int (*)())1
|
||||
@@ -3,32 +3,32 @@ abs.c
|
||||
asc.c
|
||||
asrt.c
|
||||
atn.c
|
||||
conversion.c
|
||||
error.c
|
||||
file.c
|
||||
hlt.c
|
||||
print.c
|
||||
read.c
|
||||
return.c
|
||||
salloc.c
|
||||
string.c
|
||||
trap.c
|
||||
write.c
|
||||
chr.c
|
||||
conversion.c
|
||||
hlt.c
|
||||
mki.c
|
||||
oct.c
|
||||
peek.c
|
||||
power.c
|
||||
io.c
|
||||
exp.c
|
||||
log.c
|
||||
sin.c
|
||||
sqt.c
|
||||
sgn.c
|
||||
print.c
|
||||
io.c
|
||||
random.c
|
||||
mki.c
|
||||
peek.c
|
||||
trace.c
|
||||
swap.c
|
||||
fef.e
|
||||
read.c
|
||||
return.c
|
||||
sgn.c
|
||||
sin.c
|
||||
fif.e
|
||||
oct.c
|
||||
setline.e
|
||||
sqt.c
|
||||
fef.e
|
||||
stop.c
|
||||
string.c
|
||||
salloc.c
|
||||
swap.c
|
||||
trace.c
|
||||
write.c
|
||||
file.c
|
||||
error.c
|
||||
trap.c
|
||||
setline.e
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
long _abl(i) long i;
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "string.h"
|
||||
#include "bc_string.h"
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
int _asc(str)
|
||||
String *str;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
asrt(b)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
/* Author: J.W. Stevenson */
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "string.h"
|
||||
#include "bc_string.h"
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
String *_chr(i)
|
||||
int i;
|
||||
@@ -12,6 +12,6 @@ int i;
|
||||
error(3);
|
||||
buf[0]=i;
|
||||
buf[1]=0;
|
||||
s= (String *) _newstr(buf);
|
||||
s= _newstr(buf);
|
||||
return(s);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
int _cint(f) double f;
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
/* error takes an error value in the range of 0-255 */
|
||||
/* and generates a trap */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
/* Author: J.W. Stevenson */
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "string.h"
|
||||
#include "bc_string.h"
|
||||
#include <stdio.h>
|
||||
#include "io.h"
|
||||
#include "bc_io.h"
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
Filedesc _fdtable[16];
|
||||
/* BASIC file descriptor table */
|
||||
@@ -18,7 +18,7 @@ int _chann = -1;
|
||||
FILE *_chanrd = stdin;
|
||||
FILE *_chanwr = stdout;
|
||||
|
||||
_setchannel(index)
|
||||
_setchan(index)
|
||||
int index;
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
_hlt(nr)
|
||||
int nr;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "io.h"
|
||||
#include "bc_io.h"
|
||||
#include <sgtty.h>
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
struct sgttyb _ttydef;
|
||||
|
||||
@@ -59,6 +59,7 @@ _zone()
|
||||
_in(buf)
|
||||
char *buf;
|
||||
{
|
||||
register int holder ;
|
||||
char *c;
|
||||
int pos;
|
||||
if( _chann == -1)
|
||||
@@ -69,8 +70,9 @@ char *buf;
|
||||
stty(0,_ttydef);
|
||||
}else pos= _fdtable[_chann].pos;
|
||||
c= buf;
|
||||
while( (*c = fgetc(_chanrd)) != EOF && *c != '\n'){
|
||||
if( _chann == -1) putchar(*c);
|
||||
while( (holder = fgetc(_chanrd)) != EOF && holder != '\n'){
|
||||
*c= holder ;
|
||||
if( _chann == -1) putchar(holder);
|
||||
c++; pos++;
|
||||
}
|
||||
*c= 0;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
/* Author: J.W. Stevenson */
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#include "string.h"
|
||||
#include "bc_string.h"
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
String *_mki(i)
|
||||
int i;
|
||||
long i;
|
||||
{
|
||||
char *buffer =" ";
|
||||
char *buffer =" ";
|
||||
String *s;
|
||||
|
||||
s= (String *) _newstr(buffer);
|
||||
strncpy(s->strval,&i,2);
|
||||
s= _newstr(buffer);
|
||||
* ( (long *)s->strval ) = i ;
|
||||
return(s);
|
||||
}
|
||||
String *_mkd(d)
|
||||
@@ -18,20 +18,17 @@ double d;
|
||||
char *buffer =" ";
|
||||
String *s;
|
||||
|
||||
s= (String *) _newstr(buffer);
|
||||
strncpy(s->strval,&d,8);
|
||||
s= _newstr(buffer);
|
||||
* ( (double *)s->strval ) = d ;
|
||||
return(s);
|
||||
}
|
||||
_cvi(s)
|
||||
long _cvi(s)
|
||||
String *s;
|
||||
{
|
||||
int i;
|
||||
strncpy(&i,s->strval,2);
|
||||
return(i);
|
||||
return *( (long *) s->strval) ;
|
||||
}
|
||||
double _cvd(s)
|
||||
String *s;
|
||||
{
|
||||
double d;
|
||||
strncpy(&d,s->strval,8);
|
||||
return *( (double *) s->strval) ;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "string.h"
|
||||
#include "bc_string.h"
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
String *_oct(i)
|
||||
int i;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
int peek(addr)
|
||||
int addr;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
/*
|
||||
computes a^b.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "string.h"
|
||||
#include "io.h"
|
||||
#include "bc_string.h"
|
||||
#include "bc_io.h"
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
/* Here all routine to generate terminal oriented output is located */
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
_randomize()
|
||||
_randomi()
|
||||
{
|
||||
int i;
|
||||
double f;
|
||||
_setchannel(-1);
|
||||
_setchan(-1);
|
||||
printf("Random number seed (-32768 to 32767) ? ");
|
||||
_readint(&i);
|
||||
f=i;
|
||||
_setrandom(f);
|
||||
_setrand(f);
|
||||
}
|
||||
|
||||
_setrandom(f)
|
||||
_setrand(f)
|
||||
double f;
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#include "string.h"
|
||||
#include "io.h"
|
||||
#include "bc_string.h"
|
||||
#include "bc_io.h"
|
||||
#include <ctype.h>
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
_readln()
|
||||
{
|
||||
char c;
|
||||
register int c;
|
||||
while( (c=fgetc(_chanrd)) != EOF && c!= '\n')
|
||||
;
|
||||
}
|
||||
|
||||
readskip()
|
||||
{
|
||||
char c;
|
||||
register int c;
|
||||
#ifdef DEBUG
|
||||
printf("readskip\n");
|
||||
#endif
|
||||
@@ -73,6 +73,7 @@ _readstr(s)
|
||||
String **s;
|
||||
{
|
||||
char buffer[1024];
|
||||
register int kar ;
|
||||
char *c;
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -80,17 +81,18 @@ String **s;
|
||||
#endif
|
||||
_asschn();
|
||||
c= buffer;
|
||||
*c= fgetc(_chanrd);
|
||||
while(isspace(*c) && *c!= EOF)
|
||||
*c= fgetc(_chanrd);
|
||||
if( *c== '"')
|
||||
kar= fgetc(_chanrd);
|
||||
while(isspace(kar) && kar!= EOF)
|
||||
kar= fgetc(_chanrd);
|
||||
*c=kar ;
|
||||
if( kar== '"')
|
||||
{
|
||||
/* read quoted string */
|
||||
#ifdef DEBUG
|
||||
printf("qouted string\n");
|
||||
#endif
|
||||
while( (*c= fgetc(_chanrd)) != '"' && *c!= EOF ) c++;
|
||||
ungetc(*c,_chanrd);
|
||||
while ( (kar= fgetc(_chanrd)) != EOF && kar!='"' ) *c++ = kar ;
|
||||
ungetc(kar,_chanrd);
|
||||
*c=0;
|
||||
}else
|
||||
if( isalpha(*c))
|
||||
@@ -100,10 +102,10 @@ String **s;
|
||||
#ifdef DEBUG
|
||||
printf("non-qouted string\n");
|
||||
#endif
|
||||
while( (*c= fgetc(_chanrd)) != ',' && *c!= EOF &&
|
||||
!isspace(*c) && *c!='\n')
|
||||
c++;
|
||||
ungetc(*c,_chanrd);
|
||||
while( (kar= fgetc(_chanrd)) != ',' && kar!= EOF &&
|
||||
!isspace(kar) && kar!='\n')
|
||||
*c++= kar ;
|
||||
ungetc(kar,_chanrd);
|
||||
*c=0;
|
||||
}else{
|
||||
if( ferror(_chanrd)) error(29);
|
||||
@@ -126,7 +128,7 @@ String **s;
|
||||
*s= (String *) _newstr(buffer);
|
||||
}
|
||||
|
||||
extern int _seektable[];
|
||||
extern int _seektab[];
|
||||
|
||||
_restore(line)
|
||||
int line;
|
||||
@@ -141,9 +143,9 @@ int line;
|
||||
if( line)
|
||||
{
|
||||
/* search number of lines to skip */
|
||||
for(nr=0; _seektable[nr] && _seektable[nr]< line; nr+=2)
|
||||
for(nr=0; _seektab[nr] && _seektab[nr]< line; nr+=2)
|
||||
#ifdef DEBUG
|
||||
printf("test %d %d\n",_seektable[nr], _seektable[nr+1]);
|
||||
printf("test %d %d\n",_seektab[nr], _seektab[nr+1]);
|
||||
#endif
|
||||
;
|
||||
nr /= 2;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
#define MAXNESTING 1000
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
extern char *malloc() ;
|
||||
|
||||
char * salloc(length)
|
||||
int length;
|
||||
unsigned length;
|
||||
{
|
||||
char *c, *s;
|
||||
c= (char *) malloc(length);
|
||||
if( c== (char *) -1) error(5);
|
||||
c= malloc(length);
|
||||
if( !c ) error(5);
|
||||
for(s=c;s<c+length;s++) *s = 0;
|
||||
return(c);
|
||||
}
|
||||
@@ -13,6 +15,6 @@ int length;
|
||||
sfree(c)
|
||||
char *c;
|
||||
{
|
||||
if( c== 0) return;
|
||||
if( !c ) return;
|
||||
free(c);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
_sgn(v)
|
||||
double v;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
/* Author: J.W. Stevenson */
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
/* Author: J.W. Stevenson */
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
_stop()
|
||||
{
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "string.h"
|
||||
#include "bc_string.h"
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
#define ok(X) if( X ==0) return;
|
||||
#define okr(X) if( X ==0) return(0);
|
||||
|
||||
extern char *salloc() ;
|
||||
|
||||
_len(str)
|
||||
String *str;
|
||||
{
|
||||
@@ -19,7 +21,7 @@ char *str;
|
||||
s= (String *) salloc(sizeof(String));
|
||||
s->strcount=1;
|
||||
s->strlength= strlen(str);
|
||||
s->strval= (char *) salloc(s->strlength+1);
|
||||
s->strval= salloc(s->strlength+1);
|
||||
strcpy(s->strval,str);
|
||||
return(s);
|
||||
}
|
||||
@@ -34,6 +36,8 @@ _decstr(str)
|
||||
String *str;
|
||||
{
|
||||
ok(str);
|
||||
/* Strings in ROM are initialized with this count */
|
||||
if ( str->strcount==9999 ) return ;
|
||||
str->strcount--;
|
||||
if(str->strcount<=0) _delstr(str);
|
||||
}
|
||||
@@ -51,7 +55,7 @@ String *src;
|
||||
{
|
||||
ok(src);
|
||||
sfree(src->strval);
|
||||
sfree(src);
|
||||
sfree((char *)src);
|
||||
}
|
||||
String *_concat(s1,s2)
|
||||
String *s1,*s2;
|
||||
@@ -61,12 +65,12 @@ String *s1,*s2;
|
||||
okr(s1); okr(s2);
|
||||
s= (String *) salloc(sizeof(String));
|
||||
length= _len(s1)+_len(s2)+1;
|
||||
s->strval= (char *) salloc(length);
|
||||
s->strval= salloc(length);
|
||||
strcpy(s->strval,s2->strval);
|
||||
strcat(s->strval,s1->strval);
|
||||
return(s);
|
||||
}
|
||||
_strcompare(s1,s2)
|
||||
_strcomp(s1,s2)
|
||||
String *s1,*s2;
|
||||
{
|
||||
okr(s1);okr(s2);
|
||||
@@ -83,7 +87,7 @@ int size;
|
||||
okr(s);
|
||||
if( size <0 || size >s->strlength) error(3);
|
||||
ns= (String *) salloc(sizeof(String));
|
||||
ns->strval= (char *) salloc(size+1);
|
||||
ns->strval= salloc(size+1);
|
||||
ns->strcount=1;
|
||||
for(i=0; i<size && s->strval[i];i++)
|
||||
ns->strval[i]= s->strval[i];
|
||||
@@ -102,7 +106,7 @@ int d;
|
||||
s= (String *) salloc(sizeof(String));
|
||||
s->strlength= len;
|
||||
s->strcount=1;
|
||||
s->strval= (char *) salloc(len+1);
|
||||
s->strval= salloc(len+1);
|
||||
for(i=0;i<len;i++)
|
||||
s->strval[i]= ' ';
|
||||
s->strval[i]=0;
|
||||
@@ -123,7 +127,7 @@ double d,f;
|
||||
s= (String *) salloc(sizeof(String));
|
||||
s->strlength= i;
|
||||
s->strcount=1;
|
||||
s->strval= (char *) salloc(i+1);
|
||||
s->strval= salloc(i+1);
|
||||
s->strval[i]=0;
|
||||
for(; i>=0;i--)
|
||||
s->strval[i]= j;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "string.h"
|
||||
#include "bc_string.h"
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
_intswap(i1,i2)
|
||||
int *i1,*i2;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
_trace()
|
||||
{
|
||||
_trace(i)
|
||||
int i;
|
||||
{
|
||||
printf("[%d]",i);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
/* Trap handling */
|
||||
int _trpline; /* BASIC return label */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "string.h"
|
||||
#include "io.h"
|
||||
#include "bc_string.h"
|
||||
#include "bc_io.h"
|
||||
|
||||
/* $Header $ */
|
||||
/* $Header$ */
|
||||
|
||||
/* assume that the channel has been set */
|
||||
|
||||
@@ -19,14 +19,17 @@ int i;
|
||||
if(i>0)
|
||||
if( fputc(' ',_chanwr)==EOF) error(29);
|
||||
fprintf(_chanwr,"%d",i);
|
||||
if( ferror(_chanwr) ) error(29);
|
||||
}
|
||||
_wrflt(f)
|
||||
double f;
|
||||
{
|
||||
if( fprintf(_chanwr,"%f",f)== EOF) error(29);
|
||||
fprintf(_chanwr,"%f",f);
|
||||
if( ferror(_chanwr) ) error(29);
|
||||
}
|
||||
_wrstr(s)
|
||||
String *s;
|
||||
{
|
||||
if( fprintf(_chanwr,"\"%s\"",s->strval)== EOF) error(29);
|
||||
fprintf(_chanwr,"\"%s\"",s->strval);
|
||||
if( ferror(_chanwr) ) error(29);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,16 @@ h=$d/h
|
||||
l=$d/lib
|
||||
INSTALL=$l/em_bem
|
||||
|
||||
CFLAGS = -c -I$h
|
||||
CFLAGS = -I$h
|
||||
|
||||
FILES= bem.o y.tab.o symbols.o initialize.o compile.o \
|
||||
parsepar.o yywrap.o gencode.o util.o graph.o \
|
||||
eval.o func.o split.o
|
||||
|
||||
CFILES= bem.c y.tab.c symbols.c initialize.c compile.c \
|
||||
parsepar.c yywrap.c gencode.c util.c graph.c \
|
||||
eval.c func.c split.c
|
||||
|
||||
SRC= bem.h symbols.h graph.h y.tab.h \
|
||||
bem.c basic.yacc symbols.c initialize.c compile.c \
|
||||
parsepar.c yywrap.c gencode.c util.c graph.c \
|
||||
@@ -33,12 +37,15 @@ pr:
|
||||
@pr $(SRC)
|
||||
|
||||
bem: $(FILES)
|
||||
cc -o bem $(FILES)
|
||||
$(CC) -o bem $(FILES)
|
||||
|
||||
y.tab.o : y.tab.c lex.c
|
||||
cc $(CFLAGS) y.tab.c
|
||||
y.tab.o : y.tab.c basic.lex
|
||||
$(CC) $(CFLAGS) -c y.tab.c
|
||||
|
||||
y.tab.h y.tab.c : basic.yacc
|
||||
yacc -d basic.yacc
|
||||
|
||||
$(FILES) : bem.h symbols.h graph.h y.tab.h
|
||||
|
||||
lint: $(CFILES)
|
||||
lint -phac -I$h $(CFILES)
|
||||
|
||||
@@ -101,7 +101,7 @@ Key keywords [] ={
|
||||
"print", PRINTSYM, 0, 0,
|
||||
"pos", FUNCTION, POSSYM, 0,
|
||||
"put", PUTSYM, 0, 0,
|
||||
"randomize", RANDOMIZESYM, 0, 0,
|
||||
"randomi", RANDOMIZESYM, 0, 0,
|
||||
"read", READSYM, 0, 0,
|
||||
"rem", REMSYM, 0, 0,
|
||||
"renum", ILLEGAL, 0, 0,
|
||||
@@ -224,7 +224,7 @@ char name[SIGNIFICANT+1];
|
||||
lookup()
|
||||
{
|
||||
Key *k;
|
||||
Symbol *s;
|
||||
Symbol *Sym;
|
||||
char *c;
|
||||
int i, typech;
|
||||
|
||||
@@ -239,7 +239,7 @@ lookup()
|
||||
if( isalnum( *(cptr+k->length) ) &&
|
||||
k->token==FUNCTION) continue;
|
||||
cptr += k->length;
|
||||
yylval= k->classvalue;
|
||||
yylval.integer= k->classvalue;
|
||||
if(debug) printf("lookup:%d %d\n",
|
||||
k->classvalue,k->token);
|
||||
if( k->token == FUNCTION)
|
||||
@@ -261,17 +261,17 @@ lookup()
|
||||
if( i<SIGNIFICANT) name[i++]= *c++;
|
||||
name[i]=0;
|
||||
cptr=c;
|
||||
s= (Symbol *) srchsymbol(name);
|
||||
yylval = (YYSTYPE) s;
|
||||
Sym= srchsymbol(name);
|
||||
yylval.Sptr = Sym;
|
||||
typech= typechar();
|
||||
if(s->symtype!=DEFAULTTYPE)
|
||||
if(Sym->symtype!=DEFAULTTYPE)
|
||||
{
|
||||
if(typech && typech!=s->symtype && wflag)
|
||||
if(typech && typech!=Sym->symtype && wflag)
|
||||
warning("type re-declared,ignored");
|
||||
}
|
||||
if( typech)
|
||||
s->symtype=typech;
|
||||
if(debug) printf("lookup:%d Identifier\n",s);
|
||||
Sym->symtype=typech;
|
||||
if(debug) printf("lookup:%d Identifier\n",Sym);
|
||||
if( (name[0]=='f' || name[0]=='F') &&
|
||||
(name[1]=='n' || name[1]=='N') )
|
||||
return(FUNCTID);
|
||||
@@ -322,16 +322,17 @@ number()
|
||||
cptr=c;
|
||||
if( *c != '.'){
|
||||
if( i1> MAXINT || i1<MININT) {
|
||||
dval= i1;
|
||||
/*NOSTRICT*/ dval= i1;
|
||||
return(FLTVALUE);
|
||||
}
|
||||
ival= i1;
|
||||
/*NOSTRICT*/ ival= i1;
|
||||
#ifdef YYDEBUG
|
||||
if(yydebug) printf("number:INTVALUE %d",i1);
|
||||
#endif
|
||||
return(INTVALUE);
|
||||
}
|
||||
/* handle floats */
|
||||
/*NOSTRICT*/
|
||||
f= i1; dec=0.1;
|
||||
c++;
|
||||
while( isdigit(*c)){
|
||||
@@ -365,7 +366,7 @@ scanstring()
|
||||
the EM file as well, because it is not used internally
|
||||
*/
|
||||
/* generate label here */
|
||||
yylval= genrom();
|
||||
yylval.integer= genrom();
|
||||
length=0;
|
||||
if( fputc('"',emfile) == EOF) fatal("scanstring");
|
||||
sval= cptr;
|
||||
@@ -392,9 +393,9 @@ scanstring()
|
||||
*cptr=0;
|
||||
cptr++;
|
||||
fprintf(emfile,"\\000\"\n");
|
||||
i=yylval;
|
||||
yylval= genrom();
|
||||
fprintf(emfile,"l%d,1,%d\n",i,length);
|
||||
i=yylval.integer;
|
||||
yylval.integer= genrom();
|
||||
fprintf(emfile,"l%d,9999,%d\n",i,length);
|
||||
#ifdef YYDEBUG
|
||||
if(yydebug) printf("STRVALUE found\n");
|
||||
#endif
|
||||
@@ -447,20 +448,19 @@ yylex()
|
||||
case '?': return(PRINTSYM);
|
||||
case '>':
|
||||
if( *(c+1)=='='){
|
||||
c++;c++;cptr=c; yylval= GESYM;return(RELOP);
|
||||
c++;c++;cptr=c; yylval.integer= GESYM;return(RELOP);
|
||||
}
|
||||
yylval= '>';
|
||||
yylval.integer= '>';
|
||||
cptr++;
|
||||
return(RELOP);
|
||||
break;
|
||||
case '<':
|
||||
if( *(c+1)=='='){
|
||||
c++; c++; cptr=c; yylval=LESYM; return(RELOP);
|
||||
c++; c++; cptr=c; yylval.integer=LESYM; return(RELOP);
|
||||
} else
|
||||
if( *(c+1)=='>'){
|
||||
c++; c++; cptr=c; yylval=NESYM; return(RELOP);
|
||||
c++; c++; cptr=c; yylval.integer=NESYM; return(RELOP);
|
||||
}
|
||||
yylval= '<';
|
||||
yylval.integer= '<';
|
||||
cptr++;
|
||||
return(RELOP);
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
%token ELSESYM
|
||||
%token FIELDSYM
|
||||
%token FORSYM
|
||||
%token FUNCTION
|
||||
%token FUNCTID
|
||||
%token <integer> FUNCTION
|
||||
%token <Sptr> FUNCTID
|
||||
%token INKEYSYM
|
||||
%token GETSYM
|
||||
%token GOSUBSYM
|
||||
%token GOTOSYM
|
||||
%token IFSYM
|
||||
%token <integer> IFSYM
|
||||
%token INPUTSYM
|
||||
%token LETSYM
|
||||
%token LINESYM
|
||||
@@ -48,7 +48,7 @@
|
||||
%token SWAPSYM
|
||||
%token THENSYM
|
||||
%token TOSYM
|
||||
%token TRONOFFSYM
|
||||
%token <integer> TRONOFFSYM
|
||||
%token USINGSYM
|
||||
%token USRSYM
|
||||
%token WHILESYM
|
||||
@@ -59,16 +59,22 @@
|
||||
%token INTVALUE
|
||||
%token FLTVALUE
|
||||
%token DBLVALUE
|
||||
%token STRVALUE
|
||||
%token <integer> STRVALUE
|
||||
%token UNARYSYM
|
||||
%token IDENTIFIER
|
||||
%token <Sptr> IDENTIFIER
|
||||
%token ANDSYM
|
||||
%token ORSYM
|
||||
%token VARPTR
|
||||
|
||||
%left BOOLOP
|
||||
%type <Sptr> arraydcl identifier indexed
|
||||
%type <cptr> getput
|
||||
%type <integer> exprlist expression negation compare sum term factor
|
||||
%type <integer> parmlist variable printlist inputtail funcname funccall
|
||||
|
||||
%left <integer> BOOLOP
|
||||
%left NOTSYM
|
||||
%left RELOP '=' '<' '>' LESYM GESYM NESYM
|
||||
%left '=' '<' '>' LESYM GESYM NESYM
|
||||
%left <integer> RELOP
|
||||
%left '+' '-'
|
||||
%left '*' '/' '\\' MODSYM
|
||||
%left '^'
|
||||
@@ -78,11 +84,16 @@
|
||||
#define YYDEBUG
|
||||
#include "bem.h"
|
||||
|
||||
int ival; /* parser temporary values */
|
||||
typedef union {
|
||||
int integer ;
|
||||
Symbol *Sptr ;
|
||||
char *cptr ;
|
||||
} YYSTYPE ;
|
||||
|
||||
int ival;
|
||||
double dval;
|
||||
char *sval;
|
||||
int e1,e2;
|
||||
int chann; /* input/output channel */
|
||||
|
||||
char *formatstring; /* formatstring used for printing */
|
||||
Symbol *s; /* Symbol dummy */
|
||||
@@ -147,11 +158,11 @@ illegalstmt: ILLEGAL {illegalcmd();}
|
||||
|
||||
callstmt: CALLSYM IDENTIFIER parmlist ')'
|
||||
{
|
||||
emcode("cal",proclabel(((Symbol *) $2)->symname));
|
||||
emcode("cal",proclabel($2->symname));
|
||||
while($3 -- >0) emcode("asp",EMPTRSIZE);
|
||||
}
|
||||
| CALLSYM IDENTIFIER
|
||||
{ emcode("cal",proclabel(((Symbol *) $2)->symname));}
|
||||
{ emcode("cal",proclabel($2->symname));}
|
||||
|
||||
parmlist: '(' variable { $$=1;}
|
||||
| parmlist ',' variable { $$= $1+1;}
|
||||
@@ -162,10 +173,10 @@ clearstmt: CLEARSYM {warning("statement ignored");}
|
||||
closestmt: CLOSESYM filelist
|
||||
| CLOSESYM {emcode("cal","$_close");}
|
||||
|
||||
filelist: cross intvalue { emcode("loc",$2);
|
||||
filelist: cross intvalue { emcode("loc",itoa(ival));
|
||||
emcode("cal","$_clochn");
|
||||
emcode("asp",EMINTSIZE);}
|
||||
| filelist ',' cross intvalue { emcode("loc",$4);
|
||||
| filelist ',' cross intvalue { emcode("loc",itoa(ival));
|
||||
emcode("cal","$_clochn");
|
||||
emcode("asp",EMINTSIZE);}
|
||||
|
||||
@@ -203,11 +214,11 @@ dimstmt: DIMSYM arraydcl ')' {dclarray($2);}
|
||||
| dimstmt ',' arraydcl ')' {dclarray($3);}
|
||||
;
|
||||
|
||||
arraydcl : IDENTIFIER '(' INTVALUE {$$=$1; s= (Symbol *) $1;
|
||||
arraydcl : IDENTIFIER '(' INTVALUE {$$=$1; s= $1;
|
||||
s->dimlimit[s->dimensions]=ival;
|
||||
s->dimensions++;
|
||||
}
|
||||
| arraydcl ',' INTVALUE {$$=$1; s=(Symbol *) $1;
|
||||
| arraydcl ',' INTVALUE {$$=$1; s= $1;
|
||||
if(s->dimensions<MAXDIMENSIONS)
|
||||
{
|
||||
s->dimlimit[s->dimensions]=ival;
|
||||
@@ -233,7 +244,7 @@ step : STEPSYM expression {forstep($2);}
|
||||
;
|
||||
|
||||
nextstmt: NEXTSYM IDENTIFIER {nextstmt($2);}
|
||||
| NEXTSYM { nextstmt(0);}
|
||||
| NEXTSYM { nextstmt((Symbol *)0);}
|
||||
| nextstmt ',' IDENTIFIER { nextstmt($3);}
|
||||
|
||||
getstmt: getput {emcode("loc",itoa(0));
|
||||
@@ -245,8 +256,8 @@ getstmt: getput {emcode("loc",itoa(0));
|
||||
emcode("cal",$1);
|
||||
emcode("asp",EMINTSIZE);
|
||||
}
|
||||
getput: GETSYM cross intvalue { setchannel(ival); $$= (YYSTYPE)"$_getrec";}
|
||||
| PUTSYM cross intvalue { setchannel(ival); $$= (YYSTYPE)"$_putsym";}
|
||||
getput: GETSYM cross intvalue { setchannel(ival); $$= "$_getrec";}
|
||||
| PUTSYM cross intvalue { setchannel(ival); $$= "$_putsym";}
|
||||
|
||||
gosubstmt: GOSUBSYM INTVALUE {gosubstmt(ival);}
|
||||
|
||||
@@ -328,7 +339,7 @@ mode : expression ',' {conversion($1,STRINGTYPE);}
|
||||
| ',' { emcode("lae","_iomode");}
|
||||
;
|
||||
|
||||
optionstmt: OPTIONSYM BASESYM intvalue { optionbase($3);}
|
||||
optionstmt: OPTIONSYM BASESYM intvalue { optionbase(ival);}
|
||||
|
||||
printstmt: PRINTSYM {setchannel(-1);emcode("cal","$_nl");}
|
||||
| PRINTSYM file format printlist
|
||||
@@ -351,10 +362,10 @@ printlist: expression { printstmt($1); $$=1;}
|
||||
pokestmt: POKESYM expression ',' expression {pokestmt($2,$4);}
|
||||
;
|
||||
randomizestmt: RANDOMIZESYM
|
||||
{ emcode("cal","$_randomize");}
|
||||
{ emcode("cal","$_randomi");}
|
||||
| RANDOMIZESYM expression
|
||||
{ conversion($2,INTTYPE);
|
||||
emcode("cal","$_setrandom");
|
||||
emcode("cal","$_setrand");
|
||||
emcode("asp",EMINTSIZE);}
|
||||
|
||||
readstmt: READSYM {setchannel(0);} variable { readelm($3);}
|
||||
@@ -417,8 +428,8 @@ factor : INTVALUE {$$=loadint(ival);}
|
||||
| '(' expression ')' {$$=$2;}
|
||||
| '-' factor { $$=negate($2);}
|
||||
| FLTVALUE {$$=loaddbl(dval);}
|
||||
| STRVALUE {$$=loadstr($1);}
|
||||
| variable {$$=loadvar($1);}
|
||||
| STRVALUE {$$= STRINGTYPE; loadstr($1);}
|
||||
| variable {$$=$1; loadvar($1);}
|
||||
| INKEYSYM '$' { emcode("cal","$_inkey");
|
||||
emcode("lfr",EMPTRSIZE);
|
||||
$$= STRINGTYPE;
|
||||
@@ -426,11 +437,14 @@ factor : INTVALUE {$$=loadint(ival);}
|
||||
| VARPTR '(' '#' intvalue ')' { warning("Not supported"); $$=INTTYPE;}
|
||||
| FUNCTION {$$= callfcn($1,0);}
|
||||
| FUNCTION '(' cross exprlist')' {$$=callfcn($1,$4);}
|
||||
| funcname { $$=fcnend($1);}
|
||||
| funcname funccall ')' { $$=fcnend($1,$2);}
|
||||
| funcname { $$=fcnend(0);}
|
||||
| funcname funccall ')' { $$=fcnend($2);}
|
||||
| MIDSYM '$' midparms
|
||||
{ emcode("cal","$_mid");
|
||||
emcode("asp",itoa($3));
|
||||
emcode("asp",EMINTSIZE);
|
||||
emcode("asp",EMINTSIZE);
|
||||
emcode("asp",EMPTRSIZE);
|
||||
/* emcode("asp",itoa($3)); */
|
||||
emcode("lfr",EMPTRSIZE);
|
||||
$$= STRINGTYPE;
|
||||
}
|
||||
@@ -460,4 +474,4 @@ exprlist: expression { typetable[0]= $1; $$=1;}
|
||||
#ifndef NORCSID
|
||||
static char rcs_id[] = "$Header$" ;
|
||||
#endif
|
||||
#include "lex.c"
|
||||
#include "basic.lex"
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
# define RCS_BEM "$Header$"
|
||||
#endif
|
||||
|
||||
#define POINTERSIZE 4
|
||||
#define MAXINT 32768
|
||||
#define MININT -32767
|
||||
#define EMINTSIZE "EM_WSIZE"
|
||||
@@ -26,6 +25,8 @@
|
||||
#define CHANNEL 0
|
||||
#define THRESHOLD 40 /* for splitting blocks */
|
||||
|
||||
#define void int /* Some C compilers don't know void */
|
||||
|
||||
extern char *program; /* name of source program */
|
||||
extern char *inpfile; /* input tko compiler */
|
||||
extern char *outfile; /* output from compiler */
|
||||
@@ -60,4 +61,12 @@ extern Linerecord *currline;
|
||||
extern char *itoa();
|
||||
extern char *datalabel();
|
||||
extern char *instrlabel();
|
||||
extern char *proclabel();
|
||||
extern char *typesize();
|
||||
extern char *typestring();
|
||||
extern char *salloc();
|
||||
|
||||
extern char *sprintf();
|
||||
extern char *strcpy();
|
||||
extern char *strcat();
|
||||
extern char *malloc();
|
||||
|
||||
@@ -6,13 +6,15 @@ static char rcs_id[] = "$Header$" ;
|
||||
|
||||
|
||||
/* compile the next program in the list */
|
||||
/* Here we should open the input file. (for the future) */
|
||||
|
||||
FILE *yyin;
|
||||
|
||||
compileprogram()
|
||||
compileprogram(dummyprog)
|
||||
char *dummyprog;
|
||||
{
|
||||
|
||||
while( getline())
|
||||
yyparse();
|
||||
fclose(yyin);
|
||||
(void) yyparse();
|
||||
(void) fclose(yyin);
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ int ltype,rtype,operator;
|
||||
else
|
||||
if( result==STRINGTYPE)
|
||||
{
|
||||
emcode("cal","$_strcompare");
|
||||
emcode("cal","$_strcomp");
|
||||
emcode("asp",EMPTRSIZE);
|
||||
emcode("asp",EMPTRSIZE);
|
||||
emcode("lfr",EMINTSIZE);
|
||||
@@ -321,7 +321,6 @@ int type;
|
||||
{
|
||||
/* load a simple variable its address is on the stack*/
|
||||
emcode("loi",typestring(type));
|
||||
return(type);
|
||||
}
|
||||
loadint(value)
|
||||
int value;
|
||||
@@ -343,7 +342,6 @@ loadstr(value)
|
||||
int value;
|
||||
{
|
||||
emcode("lae",datalabel(value));
|
||||
return(STRINGTYPE);
|
||||
}
|
||||
loadaddr(s)
|
||||
Symbol *s;
|
||||
|
||||
@@ -52,7 +52,11 @@ int nr;
|
||||
fprintf(tmpfile,"%d\n",currline->emlabel);
|
||||
fprintf(tmpfile," lin %d\n",nr);
|
||||
emlinecount += 2;
|
||||
if( tronoff || traceflag) emcode("cal","$_trace");
|
||||
if( tronoff || traceflag) {
|
||||
emcode("loc",itoa(nr));
|
||||
emcode("cal","$_trace");
|
||||
emcode("asp","EM_WSIZE");
|
||||
}
|
||||
}
|
||||
|
||||
emcode(operation,params)
|
||||
@@ -67,9 +71,9 @@ List *datalist=0;
|
||||
datastmt()
|
||||
{
|
||||
List *l,*l1;
|
||||
l= (List *) salloc(sizeof(List));
|
||||
/*NOSTRICT*/ l= (List *) salloc(sizeof(List));
|
||||
l->linenr= currline->linenr;
|
||||
l->emlabel= (long) ftell(datfile);
|
||||
/*NOSTRICT?*/ l->emlabel= (long) ftell(datfile);
|
||||
if( datalist==0)
|
||||
{
|
||||
datalist=l;
|
||||
@@ -89,8 +93,8 @@ datatable()
|
||||
int line=0;
|
||||
|
||||
/* called at end to generate the data seek table */
|
||||
fprintf(emfile," exa _seektable\n");
|
||||
fprintf(emfile,"_seektable\n");
|
||||
fprintf(emfile," exa _seektab\n");
|
||||
fprintf(emfile,"_seektab\n");
|
||||
l= datalist;
|
||||
while(l)
|
||||
{
|
||||
@@ -192,7 +196,7 @@ int lab;
|
||||
/* save this information too */
|
||||
|
||||
emcode("loc",itoa(0));
|
||||
emcode("cal","$_setchannel");
|
||||
emcode("cal","$_setchan");
|
||||
emcode("asp",EMINTSIZE);
|
||||
emcode("loc",itoa(lab));
|
||||
emcode("cal","$_restore");
|
||||
@@ -266,7 +270,7 @@ setchannel(val)
|
||||
int val;
|
||||
{ /* obtain file descroption */
|
||||
emcode("loc",itoa(val));
|
||||
emcode("cal","$_setchannel");
|
||||
emcode("cal","$_setchan");
|
||||
emcode("asp",EMINTSIZE);
|
||||
}
|
||||
/* The if-then-else statements */
|
||||
@@ -541,12 +545,20 @@ prolog2()
|
||||
if( dataused)
|
||||
{
|
||||
fprintf(emfile," loc 0\n");
|
||||
fprintf(emfile," cal $_setchannel\n");
|
||||
fprintf(emfile," cal $_setchan\n");
|
||||
fprintf(emfile," asp EM_WSIZE\n");
|
||||
fprintf(emfile,"datfname\n rom \"%s\"\n", datfname);
|
||||
fprintf(emfile," lae datfname\n");
|
||||
fprintf(emfile,"datfname\n rom \"%s\\0\"\n", datfname);
|
||||
fprintf(emfile,"dattyp\n rom \"i\\0\"\n");
|
||||
fprintf(emfile,"datfdes\n rom datfname,1,%d\n",
|
||||
strlen(datfname));
|
||||
fprintf(emfile,"dattdes\n rom dattyp,1,1\n");
|
||||
fprintf(emfile," lae dattdes\n");
|
||||
fprintf(emfile," lae datfdes\n");
|
||||
fprintf(emfile," loc 0\n");
|
||||
fprintf(emfile," cal $_opnchn\n");
|
||||
fprintf(emfile," asp EM_PSIZE\n");
|
||||
fprintf(emfile," asp EM_PSIZE\n");
|
||||
fprintf(emfile," asp EM_WSIZE\n");
|
||||
}
|
||||
datatable();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,13 @@ Linerecord *firstline,
|
||||
*currline,
|
||||
*lastline;
|
||||
|
||||
List *newlist()
|
||||
{
|
||||
List *l;
|
||||
/*NOSTRICT*/ l= (List *) salloc(sizeof(List));
|
||||
return(l);
|
||||
}
|
||||
|
||||
/* Line management is handled here */
|
||||
|
||||
Linerecord *srchline(nr)
|
||||
@@ -68,7 +75,7 @@ int nr;
|
||||
}
|
||||
|
||||
/* make new EM block structure */
|
||||
l= (Linerecord *) salloc(sizeof(*l));
|
||||
/*NOSTRICT*/ l= (Linerecord *) salloc(sizeof(*l));
|
||||
l->emlabel= frwrd? frwrd->emlabel: genlabel();
|
||||
l->linenr= nr;
|
||||
/* save offset into tmpfile too */
|
||||
@@ -94,7 +101,7 @@ int nr;
|
||||
|
||||
if(debug) printf("goto label %d\n",nr);
|
||||
/* update currline */
|
||||
ll= (List *) salloc( sizeof(*ll));
|
||||
ll= newlist();
|
||||
ll-> linenr=nr;
|
||||
ll-> nextlist= currline->gotos;
|
||||
currline->gotos= ll;
|
||||
@@ -108,7 +115,7 @@ int nr;
|
||||
{
|
||||
/* declare forward label */
|
||||
if(debug) printf("declare forward %d\n",nr);
|
||||
ll= (List *) salloc( sizeof(*ll));
|
||||
ll= newlist();
|
||||
ll->emlabel= genlabel();
|
||||
ll-> linenr=nr;
|
||||
ll->nextlist= forwardlabel;
|
||||
@@ -132,9 +139,8 @@ int gosubcnt=1;
|
||||
List *gosublabel()
|
||||
{
|
||||
List *l;
|
||||
int n;
|
||||
|
||||
l= (List *) salloc(sizeof(List));
|
||||
l= newlist();
|
||||
l->nextlist=0;
|
||||
l->emlabel=genlabel();
|
||||
if( gotail){
|
||||
@@ -192,7 +198,7 @@ int nr;
|
||||
{
|
||||
List *l;
|
||||
|
||||
l= (List *) salloc(sizeof(List));
|
||||
l= newlist();
|
||||
l->emlabel= gotolabel(nr);
|
||||
l->nextlist=0;
|
||||
if( jumphead==0) jumphead= jumptail= l;
|
||||
@@ -247,7 +253,7 @@ int type;
|
||||
}
|
||||
jumphead= jumptail=0; jumpcnt=0;
|
||||
|
||||
l= (List *) salloc(sizeof(List));
|
||||
l= newlist();
|
||||
l->nextlist=0;
|
||||
l->emlabel=firstlabel;
|
||||
if( gotail){
|
||||
@@ -277,12 +283,12 @@ simpleprogram()
|
||||
/* a small EM programs has been found */
|
||||
prologcode();
|
||||
prolog2();
|
||||
fclose(tmpfile);
|
||||
(void) fclose(tmpfile);
|
||||
tmpfile= fopen(tmpfname,"r");
|
||||
if( tmpfile==NULL)
|
||||
fatal("tmp file disappeared");
|
||||
while( (length=fread(buf,1,512,tmpfile)) != 0)
|
||||
fwrite(buf,1,length,emfile);
|
||||
(void) fwrite(buf,1,length,emfile);
|
||||
epilogcode();
|
||||
unlink(tmpfname);
|
||||
(void) unlink(tmpfname);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user