updated for photo-typesetter
This commit is contained in:
parent
f3e2248cc4
commit
9694054674
19 changed files with 3724 additions and 2420 deletions
|
@ -1,11 +1,14 @@
|
||||||
head: doc.pr
|
head: doc.pr
|
||||||
|
|
||||||
NROFF=nroff
|
NROFF=nroff
|
||||||
FILES = macr.nr title.nr intro.nr mem.nr ispace.nr dspace.nr mapping.nr types.nr descr.nr iotrap.nr mach.nr assem.nr app.nr
|
TBL=tbl
|
||||||
|
FILES = macr.nr title.nr intro.nr mem.nr ispace.nr dspace.nr mapping.nr \
|
||||||
|
types.nr descr.nr env.nr traps.nr mach.nr assem.nr \
|
||||||
|
app.int.nr app.codes.nr app.exam.nr cont.nr
|
||||||
IOP=../../util/ass/ip_spec.t
|
IOP=../../util/ass/ip_spec.t
|
||||||
|
|
||||||
doc.pr: $(FILES) itables em.i
|
doc.pr: $(FILES) itables em.i Makefile
|
||||||
tbl $(FILES) | $(NROFF) >doc.pr
|
$(TBL) $(FILES) | $(NROFF) >doc.pr
|
||||||
|
|
||||||
distr: $(FILES) itables em.i
|
distr: $(FILES) itables em.i
|
||||||
tbl $(FILES) | nroff -Tlp >doc.pr
|
tbl $(FILES) | nroff -Tlp >doc.pr
|
||||||
|
@ -22,10 +25,10 @@ app.t: itables em.i
|
||||||
em.i: int/em.p
|
em.i: int/em.p
|
||||||
@echo Sorry, this copy was edited by hand from int/em.p
|
@echo Sorry, this copy was edited by hand from int/em.p
|
||||||
|
|
||||||
itables: $(IOP)
|
itables: $(IOP) ip.awk
|
||||||
awk -f ip.awk $(IOP) | tbl >itables
|
awk -f ip.awk $(IOP) | sed 's/-/\\-/g" | $(TBL) >itables
|
||||||
|
|
||||||
.SUFFIXES : .pr .nr
|
.SUFFIXES : .pr .nr
|
||||||
.nr.pr: ; tbl macr.nr $*.nr | $(NROFF) >$@
|
.nr.pr: ; $(TBL) macr.nr $*.nr | $(NROFF) >$@
|
||||||
|
|
||||||
cont.t intro.t mem.t ispace.t dspace.t mapping.t succ.t descr.t iotrap.t mach.t assem.t kern.t app.t: macr.nr
|
cont.t intro.t mem.t ispace.t dspace.t mapping.t succ.t descr.t iotrap.t mach.t assem.t kern.t app.t: macr.nr
|
||||||
|
|
|
@ -1 +1,7 @@
|
||||||
Sorry, the kun macro package is not ours to distribute.
|
This it the text of IR-81,
|
||||||
|
DESCRIPTION OF A MACHINE ARCHITECTURE FOR USE WITH BLOCK STRUCTURED LANGUAGES
|
||||||
|
|
||||||
|
To print, set NROFF and TBL in the Makefile and call make.
|
||||||
|
It uses the kun macro package which is also distributed.
|
||||||
|
|
||||||
|
The directory int contains the interpreter.
|
||||||
|
|
210
doc/em/app.codes.nr
Normal file
210
doc/em/app.codes.nr
Normal file
|
@ -0,0 +1,210 @@
|
||||||
|
.BP
|
||||||
|
.AP "EM CODE TABLES"
|
||||||
|
The following table is used by the assembler for EM machine
|
||||||
|
language.
|
||||||
|
It specifies the opcodes used for each instruction and
|
||||||
|
how arguments are mapped to machine language arguments.
|
||||||
|
The table is presented in three columns,
|
||||||
|
each line in each column contains three or four fields.
|
||||||
|
Each line describes a range of interpreter opcodes by
|
||||||
|
specifying for which instruction the range is used, the type of the
|
||||||
|
opcodes (mini, shortie, etc..) and range for the instruction
|
||||||
|
argument.
|
||||||
|
.A
|
||||||
|
The first field on each line gives the EM instruction mnemonic,
|
||||||
|
the second field gives some flags.
|
||||||
|
If the opcodes are minis or shorties the third field specifies
|
||||||
|
how many minis/shorties are used.
|
||||||
|
The last field gives the number of the (first) interpreter
|
||||||
|
opcode.
|
||||||
|
.N 1
|
||||||
|
Flags :
|
||||||
|
.IS 3
|
||||||
|
.N 1
|
||||||
|
Opcode type, only one of the following may be specified.
|
||||||
|
.PS - 5 " "
|
||||||
|
.PT \-
|
||||||
|
opcode without argument
|
||||||
|
.PT m
|
||||||
|
mini
|
||||||
|
.PT s
|
||||||
|
shortie
|
||||||
|
.PT 2
|
||||||
|
opcode with 2-byte signed argument
|
||||||
|
.PT 4
|
||||||
|
opcode with 4-byte signed argument
|
||||||
|
.PT 8
|
||||||
|
opcode with 8-byte signed argument
|
||||||
|
.PE
|
||||||
|
Secondary (escaped) opcodes.
|
||||||
|
.PS - 5 " "
|
||||||
|
.PT e
|
||||||
|
The opcode thus marked is in the secondary opcode group instead
|
||||||
|
of the primary
|
||||||
|
.PE
|
||||||
|
restrictions on arguments
|
||||||
|
.PS - 5 " "
|
||||||
|
.PT N
|
||||||
|
Negative arguments only
|
||||||
|
.PT P
|
||||||
|
Positive and zero arguments only
|
||||||
|
.PE
|
||||||
|
mapping of arguments
|
||||||
|
.PS - 5 " "
|
||||||
|
.PT w
|
||||||
|
argument must be divisible by the wordsize and is divided by the
|
||||||
|
wordsize before use as opcode argument.
|
||||||
|
.PT o
|
||||||
|
argument ( possibly after division ) must be >= 1 and is
|
||||||
|
decremented before use as opcode argument
|
||||||
|
.PE
|
||||||
|
.IE
|
||||||
|
If the opcode type is 2,4 or 8 the resulting argument is used as
|
||||||
|
opcode argument (least significant byte first).
|
||||||
|
.N
|
||||||
|
If the opcode type is mini, the argument is added
|
||||||
|
to the first opcode \- if in range \- .
|
||||||
|
If the argument is negative, the absolute value minus one is
|
||||||
|
used in the algorithm above.
|
||||||
|
.N
|
||||||
|
For shorties with positive arguments the first opcode is used
|
||||||
|
for arguments in the range 0..255, the second for the range
|
||||||
|
256..511, etc..
|
||||||
|
For shorties with negative arguments the first opcode is used
|
||||||
|
for arguments in the range \-1..\-256, the second for the range
|
||||||
|
\-257..\-512, etc..
|
||||||
|
The byte following the opcode contains the least significant
|
||||||
|
byte of the argument.
|
||||||
|
First some examples of these specifications.
|
||||||
|
.PS - 5
|
||||||
|
.PT "aar mwPo 1 34"
|
||||||
|
Indicates that opcode 34 is used as a mini for Positive
|
||||||
|
instruction arguments only.
|
||||||
|
The w and o indicate division and decrementing of the
|
||||||
|
instruction argument.
|
||||||
|
Because the resulting argument must be zero ( only opcode 34 may be used
|
||||||
|
), this mini can only be used for instruction argument 2.
|
||||||
|
Conclusion: opcode 34 is for "AAR 2".
|
||||||
|
.PT "adp sP 1 41"
|
||||||
|
Opcode 41 is used as shortie for ADP with arguments in the range
|
||||||
|
0..255.
|
||||||
|
.PT "bra sN 2 60"
|
||||||
|
Opcode 60 is used as shortie for BRA with arguments \-1..\-256,
|
||||||
|
61 is used for arguments \-257..\-512.
|
||||||
|
.PT "zer e\- 145"
|
||||||
|
Escaped opcode 145 is used for ZER.
|
||||||
|
.PE
|
||||||
|
The interpreter opcode table:
|
||||||
|
.N 1
|
||||||
|
.IS 3
|
||||||
|
.DS B
|
||||||
|
.so itables
|
||||||
|
.DE 0
|
||||||
|
.IE
|
||||||
|
.P
|
||||||
|
The table above results in the following dispatch tables.
|
||||||
|
Dispatch tables are used by interpreters to jump to the
|
||||||
|
routines implementing the EM instructions, indexed by the next opcode.
|
||||||
|
Each line of the dispatch tables gives the routine names
|
||||||
|
of eight consecutive opcodes, preceded by the first opcode number
|
||||||
|
on that line.
|
||||||
|
Routine names consist of an EM mnemonic followed by a suffix.
|
||||||
|
The suffices show the encoding used for each opcode.
|
||||||
|
.N
|
||||||
|
The following suffices exist:
|
||||||
|
.N 1
|
||||||
|
.VS 1 0
|
||||||
|
.IS 4
|
||||||
|
.PS - 11
|
||||||
|
.PT .z
|
||||||
|
no arguments
|
||||||
|
.PT .l
|
||||||
|
16-bit argument
|
||||||
|
.PT .lw
|
||||||
|
16-bit argument divided by the wordsize
|
||||||
|
.PT .p
|
||||||
|
positive 16-bit argument
|
||||||
|
.PT .pw
|
||||||
|
positive 16-bit argument divided by the wordsize
|
||||||
|
.PT .n
|
||||||
|
negative 16-bit argument
|
||||||
|
.PT .nw
|
||||||
|
negative 16-bit argument divided by the wordsize
|
||||||
|
.PT .s<num>
|
||||||
|
shortie with <num> as high order argument byte
|
||||||
|
.PT .sw<num>
|
||||||
|
shortie with argument divided by the wordsize
|
||||||
|
.PT .<num>
|
||||||
|
mini with <num> as argument
|
||||||
|
.PT .<num>W
|
||||||
|
mini with <num>*wordsize as argument
|
||||||
|
.PE 3
|
||||||
|
<num> is a possibly negative integer.
|
||||||
|
.VS 1 1
|
||||||
|
.IE
|
||||||
|
The dispatch table for the 256 primary opcodes:
|
||||||
|
.DS B
|
||||||
|
.ta 7n 16n 25n 34n 43n 52n 61n 70n
|
||||||
|
0 loc.0 loc.1 loc.2 loc.3 loc.4 loc.5 loc.6 loc.7
|
||||||
|
8 loc.8 loc.9 loc.10 loc.11 loc.12 loc.13 loc.14 loc.15
|
||||||
|
16 loc.16 loc.17 loc.18 loc.19 loc.20 loc.21 loc.22 loc.23
|
||||||
|
24 loc.24 loc.25 loc.26 loc.27 loc.28 loc.29 loc.30 loc.31
|
||||||
|
32 loc.32 loc.33 aar.1W adf.s0 adi.1W adi.2W adp.l adp.1
|
||||||
|
40 adp.2 adp.s0 adp.s\-1 ads.1W and.1W asp.1W asp.2W asp.3W
|
||||||
|
48 asp.4W asp.5W asp.w0 beq.l beq.s0 bge.s0 bgt.s0 ble.s0
|
||||||
|
56 blm.s0 blt.s0 bne.s0 bra.l bra.s\-1 bra.s\-2 bra.s0 bra.s1
|
||||||
|
64 cal.1 cal.2 cal.3 cal.4 cal.5 cal.6 cal.7 cal.8
|
||||||
|
72 cal.9 cal.10 cal.11 cal.12 cal.13 cal.14 cal.15 cal.16
|
||||||
|
80 cal.17 cal.18 cal.19 cal.20 cal.21 cal.22 cal.23 cal.24
|
||||||
|
88 cal.25 cal.26 cal.27 cal.28 cal.s0 cff.z cif.z cii.z
|
||||||
|
96 cmf.s0 cmi.1W cmi.2W cmp.z cms.s0 csa.1W csb.1W dec.z
|
||||||
|
104 dee.w0 del.w\-1 dup.1W dvf.s0 dvi.1W fil.l inc.z ine.lw
|
||||||
|
112 ine.w0 inl.\-1W inl.\-2W inl.\-3W inl.w\-1 inn.s0 ior.1W ior.s0
|
||||||
|
120 lae.l lae.w0 lae.w1 lae.w2 lae.w3 lae.w4 lae.w5 lae.w6
|
||||||
|
128 lal.p lal.n lal.0 lal.\-1 lal.w0 lal.w\-1 lal.w\-2 lar.W
|
||||||
|
136 ldc.0 lde.lw lde.w0 ldl.0 ldl.w\-1 lfr.1W lfr.2W lfr.s0
|
||||||
|
144 lil.w\-1 lil.w0 lil.0 lil.1W lin.l lin.s0 lni.z loc.l
|
||||||
|
152 loc.\-1 loc.s0 loc.s\-1 loe.lw loe.w0 loe.w1 loe.w2 loe.w3
|
||||||
|
160 loe.w4 lof.l lof.1W lof.2W lof.3W lof.4W lof.s0 loi.l
|
||||||
|
168 loi.1 loi.1W loi.2W loi.3W loi.4W loi.s0 lol.pw lol.nw
|
||||||
|
176 lol.0 lol.1W lol.2W lol.3W lol.\-1W lol.\-2W lol.\-3W lol.\-4W
|
||||||
|
184 lol.\-5W lol.\-6W lol.\-7W lol.\-8W lol.w0 lol.w\-1 lxa.1 lxl.1
|
||||||
|
192 lxl.2 mlf.s0 mli.1W mli.2W rck.1W ret.0 ret.1W ret.s0
|
||||||
|
200 rmi.1W sar.1W sbf.s0 sbi.1W sbi.2W sdl.w\-1 set.s0 sil.w\-1
|
||||||
|
208 sil.w0 sli.1W ste.lw ste.w0 ste.w1 ste.w2 stf.l stf.W
|
||||||
|
216 stf.2W stf.s0 sti.1 sti.1W sti.2W sti.3W sti.4W sti.s0
|
||||||
|
224 stl.pw stl.nw stl.0 stl.1W stl.\-1W stl.\-2W stl.\-3W stl.\-4W
|
||||||
|
232 stl.\-5W stl.w\-1 teq.z tgt.z tlt.z tne.z zeq.l zeq.s0
|
||||||
|
240 zeq.s1 zer.s0 zge.s0 zgt.s0 zle.s0 zlt.s0 zne.s0 zne.s\-1
|
||||||
|
248 zre.lw zre.w0 zrl.\-1W zrl.\-2W zrl.w\-1 zrl.nw escape1 escape2
|
||||||
|
.DE 2
|
||||||
|
The list of secondary opcodes (escape1):
|
||||||
|
.N 1
|
||||||
|
.DS B
|
||||||
|
.ta 7n 16n 25n 34n 43n 52n 61n 70n
|
||||||
|
0 aar.l aar.z adf.l adf.z adi.l adi.z ads.l ads.z
|
||||||
|
8 adu.l adu.z and.l and.z asp.lw ass.l ass.z bge.l
|
||||||
|
16 bgt.l ble.l blm.l bls.l bls.z blt.l bne.l cai.z
|
||||||
|
24 cal.l cfi.z cfu.z ciu.z cmf.l cmf.z cmi.l cmi.z
|
||||||
|
32 cms.l cms.z cmu.l cmu.z com.l com.z csa.l csa.z
|
||||||
|
40 csb.l csb.z cuf.z cui.z cuu.z dee.lw del.pw del.nw
|
||||||
|
48 dup.l dus.l dus.z dvf.l dvf.z dvi.l dvi.z dvu.l
|
||||||
|
56 dvu.z fef.l fef.z fif.l fif.z inl.pw inl.nw inn.l
|
||||||
|
64 inn.z ior.l ior.z lar.l lar.z ldc.l ldf.l ldl.pw
|
||||||
|
72 ldl.nw lfr.l lil.pw lil.nw lim.z los.l los.z lor.s0
|
||||||
|
80 lpi.l lxa.l lxl.l mlf.l mlf.z mli.l mli.z mlu.l
|
||||||
|
88 mlu.z mon.z ngf.l ngf.z ngi.l ngi.z nop.z rck.l
|
||||||
|
96 rck.z ret.l rmi.l rmi.z rmu.l rmu.z rol.l rol.z
|
||||||
|
104 ror.l ror.z rtt.z sar.l sar.z sbf.l sbf.z sbi.l
|
||||||
|
112 sbi.z sbs.l sbs.z sbu.l sbu.z sde.l sdf.l sdl.pw
|
||||||
|
120 sdl.nw set.l set.z sig.z sil.pw sil.nw sim.z sli.l
|
||||||
|
128 sli.z slu.l slu.z sri.l sri.z sru.l sru.z sti.l
|
||||||
|
136 sts.l sts.z str.s0 tge.z tle.z trp.z xor.l xor.z
|
||||||
|
144 zer.l zer.z zge.l zgt.l zle.l zlt.l zne.l zrf.l
|
||||||
|
152 zrf.z zrl.pw dch.z exg.s0 exg.l exg.z lpb.z gto.l
|
||||||
|
.DE 2
|
||||||
|
Finally, the list of opcodes with four byte arguments (escape2).
|
||||||
|
.DS
|
||||||
|
.ta 7n 16n 25n 34n 43n 52n 61n 70n
|
||||||
|
0 loc
|
||||||
|
.DE 0
|
270
doc/em/app.exam.nr
Normal file
270
doc/em/app.exam.nr
Normal file
|
@ -0,0 +1,270 @@
|
||||||
|
.BP
|
||||||
|
.AP "AN EXAMPLE PROGRAM"
|
||||||
|
.DS B
|
||||||
|
.ta 4n 8n 12n 16n 20n
|
||||||
|
1 program example(output);
|
||||||
|
2 {This program just demonstrates typical EM code.}
|
||||||
|
3 type rec = record r1: integer; r2:real; r3: boolean end;
|
||||||
|
4 var mi: integer; mx:real; r:rec;
|
||||||
|
5
|
||||||
|
6 function sum(a,b:integer):integer;
|
||||||
|
7 begin
|
||||||
|
8 sum := a + b
|
||||||
|
9 end;
|
||||||
|
10
|
||||||
|
11 procedure test(var r: rec);
|
||||||
|
12 label 1;
|
||||||
|
13 var i,j: integer;
|
||||||
|
14 x,y: real;
|
||||||
|
15 b: boolean;
|
||||||
|
16 c: char;
|
||||||
|
17 a: array[1..100] of integer;
|
||||||
|
18
|
||||||
|
19 begin
|
||||||
|
20 j := 1;
|
||||||
|
21 i := 3 * j + 6;
|
||||||
|
22 x := 4.8;
|
||||||
|
23 y := x/0.5;
|
||||||
|
24 b := true;
|
||||||
|
25 c := 'z';
|
||||||
|
26 for i:= 1 to 100 do a[i] := i * i;
|
||||||
|
27 r.r1 := j+27;
|
||||||
|
28 r.r3 := b;
|
||||||
|
29 r.r2 := x+y;
|
||||||
|
30 i := sum(r.r1, a[j]);
|
||||||
|
31 while i > 0 do begin j := j + r.r1; i := i - 1 end;
|
||||||
|
32 with r do begin r3 := b; r2 := x+y; r1 := 0 end;
|
||||||
|
33 goto 1;
|
||||||
|
34 1: writeln(j, i:6, x:9:3, b)
|
||||||
|
35 end; {test}
|
||||||
|
36 begin {main program}
|
||||||
|
37 mx := 15.96;
|
||||||
|
38 mi := 99;
|
||||||
|
39 test(r)
|
||||||
|
40 end.
|
||||||
|
.DE 0
|
||||||
|
.BP
|
||||||
|
The EM code as produced by the Pascal-VU compiler is given below. Comments
|
||||||
|
have been added manually. Note that this code has already been optimized.
|
||||||
|
.DS B
|
||||||
|
.ta 1n 24n
|
||||||
|
mes 2,2,2 ; wordsize 2, pointersize 2
|
||||||
|
.1
|
||||||
|
rom 't.p\e000' ; the name of the source file
|
||||||
|
hol 552,\-32768,0 ; externals and buf occupy 552 bytes
|
||||||
|
exp $sum ; sum can be called from other modules
|
||||||
|
pro $sum,2 ; procedure sum ; 2 bytes local storage
|
||||||
|
lin 8 ; code from source line 8
|
||||||
|
ldl 0 ; load two locals ( a and b )
|
||||||
|
adi 2 ; add them
|
||||||
|
ret 2 ; return the result
|
||||||
|
end 2 ; end of procedure ( still two bytes local storage )
|
||||||
|
.2
|
||||||
|
rom 1,99,2 ; descriptor of array a[]
|
||||||
|
exp $test ; the compiler exports all level 0 procedures
|
||||||
|
pro $test,226 ; procedure test, 226 bytes local storage
|
||||||
|
.3
|
||||||
|
rom 4.8F8 ; assemble Floating point 4.8 (8 bytes) in
|
||||||
|
.4 ; global storage
|
||||||
|
rom 0.5F8 ; same for 0.5
|
||||||
|
mes 3,\-226,2,2 ; compiler temporary not referenced by address
|
||||||
|
mes 3,\-24,2,0 ; the same is true for i, j, b and c in test
|
||||||
|
mes 3,\-22,2,0
|
||||||
|
mes 3,\-4,2,0
|
||||||
|
mes 3,\-2,2,0
|
||||||
|
mes 3,\-20,8,0 ; and for x and y
|
||||||
|
mes 3,\-12,8,0
|
||||||
|
lin 20 ; maintain source line number
|
||||||
|
loc 1
|
||||||
|
stl \-4 ; j := 1
|
||||||
|
lni ; lin 21 prior to optimization
|
||||||
|
lol \-4
|
||||||
|
loc 3
|
||||||
|
mli 2
|
||||||
|
loc 6
|
||||||
|
adi 2
|
||||||
|
stl \-2 ; i := 3 * j + 6
|
||||||
|
lni ; lin 22 prior to optimization
|
||||||
|
lae .3
|
||||||
|
loi 8
|
||||||
|
lal \-12
|
||||||
|
sti 8 ; x := 4.8
|
||||||
|
lni ; lin 23 prior to optimization
|
||||||
|
lal \-12
|
||||||
|
loi 8
|
||||||
|
lae .4
|
||||||
|
loi 8
|
||||||
|
dvf 8
|
||||||
|
lal \-20
|
||||||
|
sti 8 ; y := x / 0.5
|
||||||
|
lni ; lin 24 prior to optimization
|
||||||
|
loc 1
|
||||||
|
stl \-22 ; b := true
|
||||||
|
lni ; lin 25 prior to optimization
|
||||||
|
loc 122
|
||||||
|
stl \-24 ; c := 'z'
|
||||||
|
lni ; lin 26 prior to optimization
|
||||||
|
loc 1
|
||||||
|
stl \-2 ; for i:= 1
|
||||||
|
2
|
||||||
|
lol \-2
|
||||||
|
dup 2
|
||||||
|
mli 2 ; i*i
|
||||||
|
lal \-224
|
||||||
|
lol \-2
|
||||||
|
lae .2
|
||||||
|
sar 2 ; a[i] :=
|
||||||
|
lol \-2
|
||||||
|
loc 100
|
||||||
|
beq *3 ; to 100 do
|
||||||
|
inl \-2 ; increment i and loop
|
||||||
|
bra *2
|
||||||
|
3
|
||||||
|
lin 27
|
||||||
|
lol \-4
|
||||||
|
loc 27
|
||||||
|
adi 2 ; j + 27
|
||||||
|
sil 0 ; r.r1 :=
|
||||||
|
lni ; lin 28 prior to optimization
|
||||||
|
lol \-22 ; b
|
||||||
|
lol 0
|
||||||
|
stf 10 ; r.r3 :=
|
||||||
|
lni ; lin 29 prior to optimization
|
||||||
|
lal \-20
|
||||||
|
loi 16
|
||||||
|
adf 8 ; x + y
|
||||||
|
lol 0
|
||||||
|
adp 2
|
||||||
|
sti 8 ; r.r2 :=
|
||||||
|
lni ; lin 23 prior to optimization
|
||||||
|
lal \-224
|
||||||
|
lol \-4
|
||||||
|
lae .2
|
||||||
|
lar 2 ; a[j]
|
||||||
|
lil 0 ; r.r1
|
||||||
|
cal $sum ; call now
|
||||||
|
asp 4 ; remove parameters from stack
|
||||||
|
lfr 2 ; get function result
|
||||||
|
stl \-2 ; i :=
|
||||||
|
4
|
||||||
|
lin 31
|
||||||
|
lol \-2
|
||||||
|
zle *5 ; while i > 0 do
|
||||||
|
lol \-4
|
||||||
|
lil 0
|
||||||
|
adi 2
|
||||||
|
stl \-4 ; j := j + r.r1
|
||||||
|
del \-2 ; i := i - 1
|
||||||
|
bra *4 ; loop
|
||||||
|
5
|
||||||
|
lin 32
|
||||||
|
lol 0
|
||||||
|
stl \-226 ; make copy of address of r
|
||||||
|
lol \-22
|
||||||
|
lol \-226
|
||||||
|
stf 10 ; r3 := b
|
||||||
|
lal \-20
|
||||||
|
loi 16
|
||||||
|
adf 8
|
||||||
|
lol \-226
|
||||||
|
adp 2
|
||||||
|
sti 8 ; r2 := x + y
|
||||||
|
loc 0
|
||||||
|
sil \-226 ; r1 := 0
|
||||||
|
lin 34 ; note the abscence of the unnecesary jump
|
||||||
|
lae 22 ; address of output structure
|
||||||
|
lol \-4
|
||||||
|
cal $_wri ; write integer with default width
|
||||||
|
asp 4 ; pop parameters
|
||||||
|
lae 22
|
||||||
|
lol \-2
|
||||||
|
loc 6
|
||||||
|
cal $_wsi ; write integer width 6
|
||||||
|
asp 6
|
||||||
|
lae 22
|
||||||
|
lal \-12
|
||||||
|
loi 8
|
||||||
|
loc 9
|
||||||
|
loc 3
|
||||||
|
cal $_wrf ; write fixed format real, width 9, precision 3
|
||||||
|
asp 14
|
||||||
|
lae 22
|
||||||
|
lol \-22
|
||||||
|
cal $_wrb ; write boolean, default width
|
||||||
|
asp 4
|
||||||
|
lae 22
|
||||||
|
cal $_wln ; writeln
|
||||||
|
asp 2
|
||||||
|
ret 0 ; return, no result
|
||||||
|
end 226
|
||||||
|
exp $_main
|
||||||
|
pro $_main,0 ; main program
|
||||||
|
.6
|
||||||
|
con 2,\-1,22 ; description of external files
|
||||||
|
.5
|
||||||
|
rom 15.96F8
|
||||||
|
fil .1 ; maintain source file name
|
||||||
|
lae .6 ; description of external files
|
||||||
|
lae 0 ; base of hol area to relocate buffer addresses
|
||||||
|
cal $_ini ; initialize files, etc...
|
||||||
|
asp 4
|
||||||
|
lin 37
|
||||||
|
lae .5
|
||||||
|
loi 8
|
||||||
|
lae 2
|
||||||
|
sti 8 ; mx := 15.96
|
||||||
|
lni ; lin 38 prior to optimization
|
||||||
|
loc 99
|
||||||
|
ste 0 ; mi := 99
|
||||||
|
lni ; lin 39 prior to optimization
|
||||||
|
lae 10 ; address of r
|
||||||
|
cal $test
|
||||||
|
asp 2
|
||||||
|
loc 0 ; normal exit
|
||||||
|
cal $_hlt ; cleanup and finish
|
||||||
|
asp 2
|
||||||
|
end 0
|
||||||
|
mes 5 ; reals were used
|
||||||
|
.DE 0
|
||||||
|
The compact code corresponding to the above program is listed below.
|
||||||
|
Read it horizontally, line by line, not column by column.
|
||||||
|
Each number represents a byte of compact code, printed in decimal.
|
||||||
|
The first two bytes form the magic word.
|
||||||
|
.N 1
|
||||||
|
.IS 3
|
||||||
|
.Dr 33
|
||||||
|
173 0 159 122 122 122 255 242 1 161 250 124 116 46 112 0
|
||||||
|
255 156 245 40 2 245 0 128 120 155 249 123 115 117 109 160
|
||||||
|
249 123 115 117 109 122 67 128 63 120 3 122 88 122 152 122
|
||||||
|
242 2 161 121 219 122 255 155 249 124 116 101 115 116 160 249
|
||||||
|
124 116 101 115 116 245 226 0 242 3 161 253 128 123 52 46
|
||||||
|
56 255 242 4 161 253 128 123 48 46 53 255 159 123 245 30
|
||||||
|
255 122 122 255 159 123 96 122 120 255 159 123 98 122 120 255
|
||||||
|
159 123 116 122 120 255 159 123 118 122 120 255 159 123 100 128
|
||||||
|
120 255 159 123 108 128 120 255 67 140 69 121 113 116 68 73
|
||||||
|
116 69 123 81 122 69 126 3 122 113 118 68 57 242 3 72
|
||||||
|
128 58 108 112 128 68 58 108 72 128 57 242 4 72 128 44
|
||||||
|
128 58 100 112 128 68 69 121 113 98 68 69 245 122 0 113
|
||||||
|
96 68 69 121 113 118 182 73 118 42 122 81 122 58 245 32
|
||||||
|
255 73 118 57 242 2 94 122 73 118 69 220 10 123 54 118
|
||||||
|
18 122 183 67 147 73 116 69 147 3 122 104 120 68 73 98
|
||||||
|
73 120 111 130 68 58 100 72 136 2 128 73 120 4 122 112
|
||||||
|
128 68 58 245 32 255 73 116 57 242 2 59 122 65 120 20
|
||||||
|
249 123 115 117 109 8 124 64 122 113 118 184 67 151 73 118
|
||||||
|
128 125 73 116 65 120 3 122 113 116 41 118 18 124 185 67
|
||||||
|
152 73 120 113 245 30 255 73 98 73 245 30 255 111 130 58
|
||||||
|
100 72 136 2 128 73 245 30 255 4 122 112 128 69 120 104
|
||||||
|
245 30 255 67 154 57 142 73 116 20 249 124 95 119 114 105
|
||||||
|
8 124 57 142 73 118 69 126 20 249 124 95 119 115 105 8
|
||||||
|
126 57 142 58 108 72 128 69 129 69 123 20 249 124 95 119
|
||||||
|
114 102 8 134 57 142 73 98 20 249 124 95 119 114 98 8
|
||||||
|
124 57 142 20 249 124 95 119 108 110 8 122 88 120 152 245
|
||||||
|
226 0 155 249 125 95 109 97 105 110 160 249 125 95 109 97
|
||||||
|
105 110 120 242 6 151 122 119 142 255 242 5 161 253 128 125
|
||||||
|
49 53 46 57 54 255 50 242 1 57 242 6 57 120 20 249
|
||||||
|
124 95 105 110 105 8 124 67 157 57 242 5 72 128 57 122
|
||||||
|
112 128 68 69 219 110 120 68 57 130 20 249 124 116 101 115
|
||||||
|
116 8 122 69 120 20 249 124 95 104 108 116 8 122 152 120
|
||||||
|
159 124 160 255 159 125 255
|
||||||
|
.De
|
||||||
|
.IE
|
8
doc/em/app.int.nr
Normal file
8
doc/em/app.int.nr
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
.BP
|
||||||
|
.AP "EM INTERPRETER"
|
||||||
|
.nf
|
||||||
|
.ft CW
|
||||||
|
.ta 8 16 24 32 40 48 56 64 72 80
|
||||||
|
.so em.i
|
||||||
|
.ft P
|
||||||
|
.fi
|
354
doc/em/assem.nr
354
doc/em/assem.nr
|
@ -34,7 +34,7 @@ The scope of an instruction label is its procedure.
|
||||||
.A
|
.A
|
||||||
The pseudoinstructions CON, ROM and BSS may be preceded by a
|
The pseudoinstructions CON, ROM and BSS may be preceded by a
|
||||||
line containing a
|
line containing a
|
||||||
1-8 character data label, the first character of which is a
|
1\-8 character data label, the first character of which is a
|
||||||
letter, period or underscore.
|
letter, period or underscore.
|
||||||
The period may only be followed by
|
The period may only be followed by
|
||||||
digits, the others may be followed by letters, digits and underscores.
|
digits, the others may be followed by letters, digits and underscores.
|
||||||
|
@ -66,7 +66,7 @@ They do not belong to a specific procedure.
|
||||||
All constants in EM are interpreted in the decimal base.
|
All constants in EM are interpreted in the decimal base.
|
||||||
The ASCII assembly language accepts constant expressions
|
The ASCII assembly language accepts constant expressions
|
||||||
wherever constants are allowed.
|
wherever constants are allowed.
|
||||||
The operators recognized are: +, -, *, % and / with the usual
|
The operators recognized are: +, \-, *, % and / with the usual
|
||||||
precedence order.
|
precedence order.
|
||||||
Use of the parentheses ( and ) to alter the precedence order is allowed.
|
Use of the parentheses ( and ) to alter the precedence order is allowed.
|
||||||
.S3 "Instruction arguments"
|
.S3 "Instruction arguments"
|
||||||
|
@ -109,16 +109,16 @@ integers on top of the stack are to be compared.
|
||||||
on top of the stack that specifies the size of the integers to
|
on top of the stack that specifies the size of the integers to
|
||||||
be compared.
|
be compared.
|
||||||
Thus the following two sequences are equivalent:
|
Thus the following two sequences are equivalent:
|
||||||
.N 2
|
.N 1
|
||||||
.TS
|
.TS
|
||||||
center, tab(:) ;
|
center, tab(:) ;
|
||||||
l r 30 l r.
|
l r 30 l r.
|
||||||
LDL:-10:LDL:-10
|
LDL:\-10:LDL:\-10
|
||||||
LDL:-14:LDL:-14
|
LDL:\-14:LDL:\-14
|
||||||
::LOC:4
|
::LOC:4
|
||||||
CMI:4:CMI:
|
CMI:4:CMI:
|
||||||
ZEQ:*1:ZEQ:*1
|
ZEQ:*1:ZEQ:*1
|
||||||
.TE 2
|
.TE 1
|
||||||
Section 11.1.6 shows the arguments allowed for each instruction.
|
Section 11.1.6 shows the arguments allowed for each instruction.
|
||||||
.S3 "Pseudoinstruction arguments"
|
.S3 "Pseudoinstruction arguments"
|
||||||
Pseudoinstruction arguments can be divided in two classes:
|
Pseudoinstruction arguments can be divided in two classes:
|
||||||
|
@ -139,7 +139,7 @@ initializer's size.
|
||||||
This integer is governed by the same restrictions as for
|
This integer is governed by the same restrictions as for
|
||||||
transfer of objects to/from memory.
|
transfer of objects to/from memory.
|
||||||
As in instruction arguments, initializers include expressions of the form:
|
As in instruction arguments, initializers include expressions of the form:
|
||||||
\&"LABEL+offset" and "LABEL-offset".
|
\&"LABEL+offset" and "LABEL\-offset".
|
||||||
The offset must be an unsigned decimal constant.
|
The offset must be an unsigned decimal constant.
|
||||||
The 'IUF' indicators cannot be used in the offsets.
|
The 'IUF' indicators cannot be used in the offsets.
|
||||||
.P
|
.P
|
||||||
|
@ -167,7 +167,7 @@ double quote:":\e"
|
||||||
bit pattern:\fBddd\fP:\e\fBddd\fP
|
bit pattern:\fBddd\fP:\e\fBddd\fP
|
||||||
.TE
|
.TE
|
||||||
.DE
|
.DE
|
||||||
The escape \fBddd\fP consists of the backslash followed by 1,
|
The escape \fB\eddd\fP consists of the backslash followed by 1,
|
||||||
2, or 3 octal digits specifing the value of
|
2, or 3 octal digits specifing the value of
|
||||||
the desired character.
|
the desired character.
|
||||||
If the character following a backslash is not one of those
|
If the character following a backslash is not one of those
|
||||||
|
@ -190,9 +190,9 @@ instructions and pseudoinstructions.
|
||||||
.TS
|
.TS
|
||||||
tab(:);
|
tab(:);
|
||||||
l l l.
|
l l l.
|
||||||
<cst>:\&=:integer constant (current range -2**31..2**31-1)
|
<cst>:\&=:integer constant (current range \-2**31..2**31\-1)
|
||||||
<dlb>:\&=:data label
|
<dlb>:\&=:data label
|
||||||
<arg>:\&=:<cst> or <dlb> or <dlb>+<cst> or <dlb>-<cst>
|
<arg>:\&=:<cst> or <dlb> or <dlb>+<cst> or <dlb>\-<cst>
|
||||||
<con>:\&=:integer constant, unsigned constant, floating-point constant
|
<con>:\&=:integer constant, unsigned constant, floating-point constant
|
||||||
<str>:\&=:string constant (surrounded by double quotes),
|
<str>:\&=:string constant (surrounded by double quotes),
|
||||||
<ilb>:\&=:instruction label
|
<ilb>:\&=:instruction label
|
||||||
|
@ -425,13 +425,13 @@ etc. represent the succeeding bytes.
|
||||||
tab(:) ;
|
tab(:) ;
|
||||||
rw17 4 l.
|
rw17 4 l.
|
||||||
0:Reserved for future use
|
0:Reserved for future use
|
||||||
1-129:Machine instructions, see Appendix A, alphabetical list
|
1\-129:Machine instructions, see Appendix A, alphabetical list
|
||||||
130-149:Reserved for future use
|
130\-149:Reserved for future use
|
||||||
150-161:BSS,CON,END,EXA,EXC,EXP,HOL,INA,INP,MES,PRO,ROM
|
150\-161:BSS,CON,END,EXA,EXC,EXP,HOL,INA,INP,MES,PRO,ROM
|
||||||
162-179:Reserved for future pseudoinstructions
|
162\-179:Reserved for future pseudoinstructions
|
||||||
180-239:Instruction labels 0 - 59 (180 is local label 0 etc.)
|
180\-239:Instruction labels 0 \- 59 (180 is local label 0 etc.)
|
||||||
240-244:See the Common Table below
|
240\-244:See the Common Table below
|
||||||
245-255:Not used
|
245\-255:Not used
|
||||||
.TE 1
|
.TE 1
|
||||||
.DE 0
|
.DE 0
|
||||||
After a label, the assembler is back in neutral state; it can immediately
|
After a label, the assembler is back in neutral state; it can immediately
|
||||||
|
@ -449,9 +449,9 @@ encoded as follows:
|
||||||
.TS
|
.TS
|
||||||
tab(:);
|
tab(:);
|
||||||
r l.
|
r l.
|
||||||
0-239:Offsets from -120 to 119
|
0\-239:Offsets from \-120 to 119
|
||||||
|
|
||||||
240-255:See the Common Table below
|
240\-255:See the Common Table below
|
||||||
.TE 1
|
.TE 1
|
||||||
Absence of an optional argument is indicated by a special
|
Absence of an optional argument is indicated by a special
|
||||||
byte.
|
byte.
|
||||||
|
@ -467,8 +467,8 @@ class:bytes:description
|
||||||
|
|
||||||
<ilb>:240:b1:Instruction label b1 (Not used for branches)
|
<ilb>:240:b1:Instruction label b1 (Not used for branches)
|
||||||
<ilb>:241:b1 b2:16 bit instruction label (256*b2 + b1)
|
<ilb>:241:b1 b2:16 bit instruction label (256*b2 + b1)
|
||||||
<dlb>:242:b1:Global label .0-.255, with b1 being the label
|
<dlb>:242:b1:Global label .0\-.255, with b1 being the label
|
||||||
<dlb>:243:b1 b2:Global label .0-.32767
|
<dlb>:243:b1 b2:Global label .0\-.32767
|
||||||
:::with 256*b2+b1 being the label
|
:::with 256*b2+b1 being the label
|
||||||
<dlb>:244:<string>:Global symbol not of the form .nnn
|
<dlb>:244:<string>:Global symbol not of the form .nnn
|
||||||
<cst>:245:b1 b2:16 bit constant
|
<cst>:245:b1 b2:16 bit constant
|
||||||
|
@ -488,7 +488,7 @@ class:bytes:description
|
||||||
The bytes specifying the value of a 16, 32 or 64 bit constant
|
The bytes specifying the value of a 16, 32 or 64 bit constant
|
||||||
are presented in two's complement notation, with the least
|
are presented in two's complement notation, with the least
|
||||||
significant byte first. For example: the value of a 32 bit
|
significant byte first. For example: the value of a 32 bit
|
||||||
constant is ((s4*256+b3)*256+b2)*256+b1, where s4 is b4-256 if
|
constant is ((s4*256+b3)*256+b2)*256+b1, where s4 is b4\-256 if
|
||||||
b4 is greater than 128 else s4 takes the value of b4.
|
b4 is greater than 128 else s4 takes the value of b4.
|
||||||
A <string> consists of a <cst> inmediatly followed by
|
A <string> consists of a <cst> inmediatly followed by
|
||||||
a sequence of bytes with length <cst>.
|
a sequence of bytes with length <cst>.
|
||||||
|
@ -498,10 +498,10 @@ The pseudoinstructions fall into several categories, depending on their
|
||||||
arguments:
|
arguments:
|
||||||
.N 1
|
.N 1
|
||||||
.DS
|
.DS
|
||||||
Group 1 -- EXC, BSS, HOL have a known number of arguments
|
Group 1 \- EXC, BSS, HOL have a known number of arguments
|
||||||
Group 2 -- EXA, EXP, INA, INP have a string as argument
|
Group 2 \- EXA, EXP, INA, INP have a string as argument
|
||||||
Group 3 -- CON, MES, ROM have a variable number of various things
|
Group 3 \- CON, MES, ROM have a variable number of various things
|
||||||
Group 4 -- END, PRO have a trailing optional argument.
|
Group 4 \- END, PRO have a trailing optional argument.
|
||||||
.DE 1
|
.DE 1
|
||||||
Groups 1 and 2
|
Groups 1 and 2
|
||||||
use the encoding described above.
|
use the encoding described above.
|
||||||
|
@ -522,7 +522,7 @@ Example ASCII|Example compact
|
||||||
2||182
|
2||182
|
||||||
1||181
|
1||181
|
||||||
LOC|10|69 130
|
LOC|10|69 130
|
||||||
LOC|-10|69 110
|
LOC|\-10|69 110
|
||||||
LOC|300|69 245 44 1
|
LOC|300|69 245 44 1
|
||||||
BRA|*19|18 139
|
BRA|*19|18 139
|
||||||
300||241 44 1
|
300||241 44 1
|
||||||
|
@ -531,7 +531,6 @@ Example ASCII|Example compact
|
||||||
CON|.35|151 242 35 255
|
CON|.35|151 242 35 255
|
||||||
.TE 0
|
.TE 0
|
||||||
.IE 0
|
.IE 0
|
||||||
.BP
|
|
||||||
.S2 "Assembly language instruction list"
|
.S2 "Assembly language instruction list"
|
||||||
.P
|
.P
|
||||||
For each instruction in the list the range of argument values
|
For each instruction in the list the range of argument values
|
||||||
|
@ -556,7 +555,7 @@ are indicated by letters:
|
||||||
.ds s \fBs\fP
|
.ds s \fBs\fP
|
||||||
.ds z \fBz\fP
|
.ds z \fBz\fP
|
||||||
.ds o \fBo\fP
|
.ds o \fBo\fP
|
||||||
.ds - \fB-\fP
|
.ds - \fB\-\fP
|
||||||
.N 1
|
.N 1
|
||||||
.TS
|
.TS
|
||||||
tab(:);
|
tab(:);
|
||||||
|
@ -590,184 +589,185 @@ values and underflow or overflow
|
||||||
are indicated below by (*).
|
are indicated below by (*).
|
||||||
.N 1
|
.N 1
|
||||||
.DS B
|
.DS B
|
||||||
GROUP 1 - LOAD
|
.ta 12n
|
||||||
|
GROUP 1 \- LOAD
|
||||||
|
|
||||||
LOC \*c : Load constant (i.e. push one word onto the stack)
|
LOC \*c : Load constant (i.e. push one word onto the stack)
|
||||||
LDC \*d : Load double constant ( push two words )
|
LDC \*d : Load double constant ( push two words )
|
||||||
LOL \*l : Load word at \*l-th local (\*l<0) or parameter (\*l>=0)
|
LOL \*l : Load word at \*l-th local (\*l<0) or parameter (\*l>=0)
|
||||||
LOE \*g : Load external word \*g
|
LOE \*g : Load external word \*g
|
||||||
LIL \*l : Load word pointed to by \*l-th local or parameter
|
LIL \*l : Load word pointed to by \*l-th local or parameter
|
||||||
LOF \*f : Load offsetted (top of stack + \*f yield address)
|
LOF \*f : Load offsetted (top of stack + \*f yield address)
|
||||||
LAL \*l : Load address of local or parameter
|
LAL \*l : Load address of local or parameter
|
||||||
LAE \*g : Load address of external
|
LAE \*g : Load address of external
|
||||||
LXL \*n : Load lexical (address of LB \*n static levels back)
|
LXL \*n : Load lexical (address of LB \*n static levels back)
|
||||||
LXA \*n : Load lexical (address of AB \*n static levels back)
|
LXA \*n : Load lexical (address of AB \*n static levels back)
|
||||||
LOI \*o : Load indirect \*o bytes (address is popped from the stack)
|
LOI \*o : Load indirect \*o bytes (address is popped from the stack)
|
||||||
LOS \*w : Load indirect, \*w-byte integer on top of stack gives object size
|
LOS \*w : Load indirect, \*w-byte integer on top of stack gives object size
|
||||||
LDL \*l : Load double local or parameter (two consecutive words are stacked)
|
LDL \*l : Load double local or parameter (two consecutive words are stacked)
|
||||||
LDE \*g : Load double external (two consecutive externals are stacked)
|
LDE \*g : Load double external (two consecutive externals are stacked)
|
||||||
LDF \*f : Load double offsetted (top of stack + \*f yield address)
|
LDF \*f : Load double offsetted (top of stack + \*f yield address)
|
||||||
LPI \*p : Load procedure identifier
|
LPI \*p : Load procedure identifier
|
||||||
|
|
||||||
GROUP 2 - STORE
|
GROUP 2 \- STORE
|
||||||
|
|
||||||
STL \*l : Store local or parameter
|
STL \*l : Store local or parameter
|
||||||
STE \*g : Store external
|
STE \*g : Store external
|
||||||
SIL \*l : Store into word pointed to by \*l-th local or parameter
|
SIL \*l : Store into word pointed to by \*l-th local or parameter
|
||||||
STF \*f : Store offsetted
|
STF \*f : Store offsetted
|
||||||
STI \*o : Store indirect \*o bytes (pop address, then data)
|
STI \*o : Store indirect \*o bytes (pop address, then data)
|
||||||
STS \*w : Store indirect, \*w-byte integer on top of stack gives object size
|
STS \*w : Store indirect, \*w-byte integer on top of stack gives object size
|
||||||
SDL \*l : Store double local or parameter
|
SDL \*l : Store double local or parameter
|
||||||
SDE \*g : Store double external
|
SDE \*g : Store double external
|
||||||
SDF \*f : Store double offsetted
|
SDF \*f : Store double offsetted
|
||||||
|
|
||||||
GROUP 3 - INTEGER ARITHMETIC
|
GROUP 3 \- INTEGER ARITHMETIC
|
||||||
|
|
||||||
ADI \*w : Addition (*)
|
ADI \*w : Addition (*)
|
||||||
SBI \*w : Subtraction (*)
|
SBI \*w : Subtraction (*)
|
||||||
MLI \*w : Multiplication (*)
|
MLI \*w : Multiplication (*)
|
||||||
DVI \*w : Division (*)
|
DVI \*w : Division (*)
|
||||||
RMI \*w : Remainder (*)
|
RMI \*w : Remainder (*)
|
||||||
NGI \*w : Negate (two's complement) (*)
|
NGI \*w : Negate (two's complement) (*)
|
||||||
SLI \*w : Shift left (*)
|
SLI \*w : Shift left (*)
|
||||||
SRI \*w : Shift right (*)
|
SRI \*w : Shift right (*)
|
||||||
|
|
||||||
GROUP 4 - UNSIGNED ARITHMETIC
|
GROUP 4 \- UNSIGNED ARITHMETIC
|
||||||
|
|
||||||
ADU \*w : Addition
|
ADU \*w : Addition
|
||||||
SBU \*w : Subtraction
|
SBU \*w : Subtraction
|
||||||
MLU \*w : Multiplication
|
MLU \*w : Multiplication
|
||||||
DVU \*w : Division
|
DVU \*w : Division
|
||||||
RMU \*w : Remainder
|
RMU \*w : Remainder
|
||||||
SLU \*w : Shift left
|
SLU \*w : Shift left
|
||||||
SRU \*w : Shift right
|
SRU \*w : Shift right
|
||||||
|
|
||||||
GROUP 5 - FLOATING POINT ARITHMETIC
|
GROUP 5 \- FLOATING POINT ARITHMETIC
|
||||||
|
|
||||||
ADF \*w : Floating add (*)
|
ADF \*w : Floating add (*)
|
||||||
SBF \*w : Floating subtract (*)
|
SBF \*w : Floating subtract (*)
|
||||||
MLF \*w : Floating multiply (*)
|
MLF \*w : Floating multiply (*)
|
||||||
DVF \*w : Floating divide (*)
|
DVF \*w : Floating divide (*)
|
||||||
NGF \*w : Floating negate (*)
|
NGF \*w : Floating negate (*)
|
||||||
FIF \*w : Floating multiply and split integer and fraction part (*)
|
FIF \*w : Floating multiply and split integer and fraction part (*)
|
||||||
FEF \*w : Split floating number in exponent and fraction part (*)
|
FEF \*w : Split floating number in exponent and fraction part (*)
|
||||||
|
|
||||||
GROUP 6 - POINTER ARITHMETIC
|
GROUP 6 \- POINTER ARITHMETIC
|
||||||
|
|
||||||
ADP \*f : Add \*f to pointer on top of stack
|
ADP \*f : Add \*f to pointer on top of stack
|
||||||
ADS \*w : Add \*w-byte value and pointer
|
ADS \*w : Add \*w-byte value and pointer
|
||||||
SBS \*w : Subtract pointers in same fragment and push diff as size \*w integer
|
SBS \*w : Subtract pointers in same fragment and push diff as size \*w integer
|
||||||
|
|
||||||
GROUP 7 - INCREMENT/DECREMENT/ZERO
|
GROUP 7 \- INCREMENT/DECREMENT/ZERO
|
||||||
|
|
||||||
INC \*- : Increment word on top of stack by 1 (*)
|
INC \*- : Increment word on top of stack by 1 (*)
|
||||||
INL \*l : Increment local or parameter (*)
|
INL \*l : Increment local or parameter (*)
|
||||||
INE \*g : Increment external (*)
|
INE \*g : Increment external (*)
|
||||||
DEC \*- : Decrement word on top of stack by 1 (*)
|
DEC \*- : Decrement word on top of stack by 1 (*)
|
||||||
DEL \*l : Decrement local or parameter (*)
|
DEL \*l : Decrement local or parameter (*)
|
||||||
DEE \*g : Decrement external (*)
|
DEE \*g : Decrement external (*)
|
||||||
ZRL \*l : Zero local or parameter
|
ZRL \*l : Zero local or parameter
|
||||||
ZRE \*g : Zero external
|
ZRE \*g : Zero external
|
||||||
ZRF \*w : Load a floating zero of size \*w
|
ZRF \*w : Load a floating zero of size \*w
|
||||||
ZER \*w : Load \*w zero bytes
|
ZER \*w : Load \*w zero bytes
|
||||||
|
|
||||||
GROUP 8 - CONVERT (stack: source, source size, dest. size (top))
|
GROUP 8 \- CONVERT (stack: source, source size, dest. size (top))
|
||||||
|
|
||||||
CII \*- : Convert integer to integer (*)
|
CII \*- : Convert integer to integer (*)
|
||||||
CUI \*- : Convert unsigned to integer (*)
|
CUI \*- : Convert unsigned to integer (*)
|
||||||
CFI \*- : Convert floating to integer (*)
|
CFI \*- : Convert floating to integer (*)
|
||||||
CIF \*- : Convert integer to floating (*)
|
CIF \*- : Convert integer to floating (*)
|
||||||
CUF \*- : Convert unsigned to floating (*)
|
CUF \*- : Convert unsigned to floating (*)
|
||||||
CFF \*- : Convert floating to floating (*)
|
CFF \*- : Convert floating to floating (*)
|
||||||
CIU \*- : Convert integer to unsigned
|
CIU \*- : Convert integer to unsigned
|
||||||
CUU \*- : Convert unsigned to unsigned
|
CUU \*- : Convert unsigned to unsigned
|
||||||
CFU \*- : Convert floating to unsigned
|
CFU \*- : Convert floating to unsigned
|
||||||
|
|
||||||
GROUP 9 - LOGICAL
|
GROUP 9 \- LOGICAL
|
||||||
|
|
||||||
AND \*w : Boolean and on two groups of \*w bytes
|
AND \*w : Boolean and on two groups of \*w bytes
|
||||||
IOR \*w : Boolean inclusive or on two groups of \*w bytes
|
IOR \*w : Boolean inclusive or on two groups of \*w bytes
|
||||||
XOR \*w : Boolean exclusive or on two groups of \*w bytes
|
XOR \*w : Boolean exclusive or on two groups of \*w bytes
|
||||||
COM \*w : Complement (one's complement of top \*w bytes)
|
COM \*w : Complement (one's complement of top \*w bytes)
|
||||||
ROL \*w : Rotate left a group of \*w bytes
|
ROL \*w : Rotate left a group of \*w bytes
|
||||||
ROR \*w : Rotate right a group of \*w bytes
|
ROR \*w : Rotate right a group of \*w bytes
|
||||||
|
|
||||||
GROUP 10 - SETS
|
GROUP 10 \- SETS
|
||||||
|
|
||||||
INN \*w : Bit test on \*w byte set (bit number on top of stack)
|
INN \*w : Bit test on \*w byte set (bit number on top of stack)
|
||||||
SET \*w : Create singleton \*w byte set with bit n on (n is top of stack)
|
SET \*w : Create singleton \*w byte set with bit n on (n is top of stack)
|
||||||
|
|
||||||
GROUP 11 - ARRAY
|
GROUP 11 \- ARRAY
|
||||||
|
|
||||||
LAR \*w : Load array element, descriptor contains integers of size \*w
|
LAR \*w : Load array element, descriptor contains integers of size \*w
|
||||||
SAR \*w : Store array element
|
SAR \*w : Store array element
|
||||||
AAR \*w : Load address of array element
|
AAR \*w : Load address of array element
|
||||||
|
|
||||||
GROUP 12 - COMPARE
|
GROUP 12 \- COMPARE
|
||||||
|
|
||||||
CMI \*w : Compare \*w byte integers, Push negative, zero, positive for <, = or >
|
CMI \*w : Compare \*w byte integers, Push negative, zero, positive for <, = or >
|
||||||
CMF \*w : Compare \*w byte reals
|
CMF \*w : Compare \*w byte reals
|
||||||
CMU \*w : Compare \*w byte unsigneds
|
CMU \*w : Compare \*w byte unsigneds
|
||||||
CMS \*w : Compare \*w byte values, can only be used for bit for bit equality test
|
CMS \*w : Compare \*w byte values, can only be used for bit for bit equality test
|
||||||
CMP \*- : Compare pointers
|
CMP \*- : Compare pointers
|
||||||
|
|
||||||
TLT \*- : True if less, i.e. iff top of stack < 0
|
TLT \*- : True if less, i.e. iff top of stack < 0
|
||||||
TLE \*- : True if less or equal, i.e. iff top of stack <= 0
|
TLE \*- : True if less or equal, i.e. iff top of stack <= 0
|
||||||
TEQ \*- : True if equal, i.e. iff top of stack = 0
|
TEQ \*- : True if equal, i.e. iff top of stack = 0
|
||||||
TNE \*- : True if not equal, i.e. iff top of stack non zero
|
TNE \*- : True if not equal, i.e. iff top of stack non zero
|
||||||
TGE \*- : True if greater or equal, i.e. iff top of stack >= 0
|
TGE \*- : True if greater or equal, i.e. iff top of stack >= 0
|
||||||
TGT \*- : True if greater, i.e. iff top of stack > 0
|
TGT \*- : True if greater, i.e. iff top of stack > 0
|
||||||
|
|
||||||
GROUP 13 - BRANCH
|
GROUP 13 \- BRANCH
|
||||||
|
|
||||||
BRA \*b : Branch unconditionally to label \*b
|
BRA \*b : Branch unconditionally to label \*b
|
||||||
|
|
||||||
BLT \*b : Branch less (pop 2 words, branch if top > second)
|
BLT \*b : Branch less (pop 2 words, branch if top > second)
|
||||||
BLE \*b : Branch less or equal
|
BLE \*b : Branch less or equal
|
||||||
BEQ \*b : Branch equal
|
BEQ \*b : Branch equal
|
||||||
BNE \*b : Branch not equal
|
BNE \*b : Branch not equal
|
||||||
BGE \*b : Branch greater or equal
|
BGE \*b : Branch greater or equal
|
||||||
BGT \*b : Branch greater
|
BGT \*b : Branch greater
|
||||||
|
|
||||||
ZLT \*b : Branch less than zero (pop 1 word, branch negative)
|
ZLT \*b : Branch less than zero (pop 1 word, branch negative)
|
||||||
ZLE \*b : Branch less or equal to zero
|
ZLE \*b : Branch less or equal to zero
|
||||||
ZEQ \*b : Branch equal zero
|
ZEQ \*b : Branch equal zero
|
||||||
ZNE \*b : Branch not zero
|
ZNE \*b : Branch not zero
|
||||||
ZGE \*b : Branch greater or equal zero
|
ZGE \*b : Branch greater or equal zero
|
||||||
ZGT \*b : Branch greater than zero
|
ZGT \*b : Branch greater than zero
|
||||||
|
|
||||||
GROUP 14 - PROCEDURE CALL
|
GROUP 14 \- PROCEDURE CALL
|
||||||
|
|
||||||
CAI \*- : Call procedure (procedure identifier on stack)
|
CAI \*- : Call procedure (procedure identifier on stack)
|
||||||
CAL \*p : Call procedure (with identifier \*p)
|
CAL \*p : Call procedure (with identifier \*p)
|
||||||
LFR \*s : Load function result
|
LFR \*s : Load function result
|
||||||
RET \*z : Return (function result consists of top \*z bytes)
|
RET \*z : Return (function result consists of top \*z bytes)
|
||||||
|
|
||||||
GROUP 15 - MISCELLANEOUS
|
GROUP 15 \- MISCELLANEOUS
|
||||||
|
|
||||||
ASP \*f : Adjust the stack pointer by \*f
|
ASP \*f : Adjust the stack pointer by \*f
|
||||||
ASS \*w : Adjust the stack pointer by \*w-byte integer
|
ASS \*w : Adjust the stack pointer by \*w-byte integer
|
||||||
BLM \*z : Block move \*z bytes; first pop destination addr, then source addr
|
BLM \*z : Block move \*z bytes; first pop destination addr, then source addr
|
||||||
BLS \*w : Block move, size is in \*w-byte integer on top of stack
|
BLS \*w : Block move, size is in \*w-byte integer on top of stack
|
||||||
CSA \*w : Case jump; address of jump table at top of stack
|
CSA \*w : Case jump; address of jump table at top of stack
|
||||||
CSB \*w : Table lookup jump; address of jump table at top of stack
|
CSB \*w : Table lookup jump; address of jump table at top of stack
|
||||||
DCH \*- : Follow dynamic chain, convert LB to LB of caller
|
DCH \*- : Follow dynamic chain, convert LB to LB of caller
|
||||||
DUP \*s : Duplicate top \*s bytes
|
DUP \*s : Duplicate top \*s bytes
|
||||||
DUS \*w : Duplicate top \*w bytes
|
DUS \*w : Duplicate top \*w bytes
|
||||||
EXG \*w : Exchange top \*w bytes
|
EXG \*w : Exchange top \*w bytes
|
||||||
FIL \*g : File name (external 4 := \*g)
|
FIL \*g : File name (external 4 := \*g)
|
||||||
GTO \*g : Non-local goto, descriptor at \*g
|
GTO \*g : Non-local goto, descriptor at \*g
|
||||||
LIM \*- : Load 16 bit ignore mask
|
LIM \*- : Load 16 bit ignore mask
|
||||||
LIN \*n : Line number (external 0 := \*n)
|
LIN \*n : Line number (external 0 := \*n)
|
||||||
LNI \*- : Line number increment
|
LNI \*- : Line number increment
|
||||||
LOR \*r : Load register (0=LB, 1=SP, 2=HP)
|
LOR \*r : Load register (0=LB, 1=SP, 2=HP)
|
||||||
LPB \*- : Convert local base to argument base
|
LPB \*- : Convert local base to argument base
|
||||||
MON \*- : Monitor call
|
MON \*- : Monitor call
|
||||||
NOP \*- : No operation
|
NOP \*- : No operation
|
||||||
RCK \*w : Range check; trap on error
|
RCK \*w : Range check; trap on error
|
||||||
RTT \*- : Return from trap
|
RTT \*- : Return from trap
|
||||||
SIG \*- : Trap errors to proc identifier on top of stack, -2 resets default
|
SIG \*- : Trap errors to proc identifier on top of stack, \-2 resets default
|
||||||
SIM \*- : Store 16 bit ignore mask
|
SIM \*- : Store 16 bit ignore mask
|
||||||
STR \*r : Store register (0=LB, 1=SP, 2=HP)
|
STR \*r : Store register (0=LB, 1=SP, 2=HP)
|
||||||
TRP \*- : Cause trap to occur (Error number on stack)
|
TRP \*- : Cause trap to occur (Error number on stack)
|
||||||
.DE 0
|
.DE 0
|
||||||
|
|
6
doc/em/cont.nr
Normal file
6
doc/em/cont.nr
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.MS T A 0
|
||||||
|
.ME
|
||||||
|
.BP
|
||||||
|
.MS B A 0
|
||||||
|
.ME
|
||||||
|
.CT
|
|
@ -36,7 +36,7 @@ Array descriptors contain the following three integers:
|
||||||
.PT
|
.PT
|
||||||
lower bound~~~~~~~~~~~~~~~~~~~~~signed
|
lower bound~~~~~~~~~~~~~~~~~~~~~signed
|
||||||
.PT
|
.PT
|
||||||
upper bound - lower bound~~~~~~~unsigned
|
upper bound \- lower bound~~~~~~~unsigned
|
||||||
.PT
|
.PT
|
||||||
number of bytes per element~~~~~unsigned
|
number of bytes per element~~~~~unsigned
|
||||||
.PE
|
.PE
|
||||||
|
@ -60,7 +60,7 @@ LAR n (n is the size of the integers in the descriptor and I)
|
||||||
All array instructions first pop the address of the descriptor
|
All array instructions first pop the address of the descriptor
|
||||||
and the index.
|
and the index.
|
||||||
If the index is not within the bounds specified, a trap occurs.
|
If the index is not within the bounds specified, a trap occurs.
|
||||||
If ok, (I~-~lower bound) is multiplied
|
If ok, (I~\-~lower bound) is multiplied
|
||||||
by the number of bytes per element (the third word). The result is added
|
by the number of bytes per element (the third word). The result is added
|
||||||
to the address of A and replaces A on the stack.
|
to the address of A and replaces A on the stack.
|
||||||
.A
|
.A
|
||||||
|
@ -128,12 +128,12 @@ each source language case statement
|
||||||
is up to the front end.
|
is up to the front end.
|
||||||
If the range of the index value is dense, i.e
|
If the range of the index value is dense, i.e
|
||||||
.DS
|
.DS
|
||||||
(highest value - lowest value) / number of cases
|
(highest value \- lowest value) / number of cases
|
||||||
.DE 1
|
.DE 1
|
||||||
is less than some threshold, then CSA is the obvious choice.
|
is less than some threshold, then CSA is the obvious choice.
|
||||||
If the range is sparse, CSB is better.
|
If the range is sparse, CSB is better.
|
||||||
.N 2
|
.N 2
|
||||||
.DS
|
.Dr 30
|
||||||
|--------------------| |--------------------| high address
|
|--------------------| |--------------------| high address
|
||||||
| pointer for upb | | pointer n-1 |
|
| pointer for upb | | pointer n-1 |
|
||||||
|--------------------| |- - - - - - - |
|
|--------------------| |- - - - - - - |
|
||||||
|
@ -157,7 +157,6 @@ If the range is sparse, CSB is better.
|
||||||
|--------------------| |--------------------|
|
|--------------------| |--------------------|
|
||||||
|
|
||||||
CSA descriptor CSB descriptor
|
CSA descriptor CSB descriptor
|
||||||
|
.Df
|
||||||
|
|
||||||
Figure 4. Descriptor layout for CSA and CSB
|
Figure 4. Descriptor layout for CSA and CSB
|
||||||
.DE
|
.De
|
||||||
|
|
|
@ -23,7 +23,7 @@ Examples are LOE, LAE and STE.
|
||||||
Part of the global data area is initialized by the
|
Part of the global data area is initialized by the
|
||||||
compiler, the
|
compiler, the
|
||||||
rest is not initialized at all or is initialized
|
rest is not initialized at all or is initialized
|
||||||
with a value, typically -32768 or 0.
|
with a value, typically \-32768 or 0.
|
||||||
Part of the initialized global data may be made read-only
|
Part of the initialized global data may be made read-only
|
||||||
if the implementation supports protection.
|
if the implementation supports protection.
|
||||||
.P
|
.P
|
||||||
|
@ -47,7 +47,7 @@ addressed with the use of the DCH instruction.
|
||||||
.A
|
.A
|
||||||
Many instructions have offsets to LB as argument,
|
Many instructions have offsets to LB as argument,
|
||||||
for instance LOL, LAL and STL.
|
for instance LOL, LAL and STL.
|
||||||
The arguments of these instructions range from -1 to some
|
The arguments of these instructions range from \-1 to some
|
||||||
(negative) minimum
|
(negative) minimum
|
||||||
for the access of local storage and from 0 to some (positive)
|
for the access of local storage and from 0 to some (positive)
|
||||||
maximum for parameter access.
|
maximum for parameter access.
|
||||||
|
@ -246,7 +246,7 @@ reserved.
|
||||||
The parameters and local storage are accessed by the same instructions.
|
The parameters and local storage are accessed by the same instructions.
|
||||||
Negative offsets are used for access to local variables.
|
Negative offsets are used for access to local variables.
|
||||||
The highest byte, that is the byte nearest
|
The highest byte, that is the byte nearest
|
||||||
to LB, has to be accessed with offset -1.
|
to LB, has to be accessed with offset \-1.
|
||||||
The pseudoinstruction specifying the entry point of a
|
The pseudoinstruction specifying the entry point of a
|
||||||
procedure, has an argument that specifies the amount of local
|
procedure, has an argument that specifies the amount of local
|
||||||
storage needed.
|
storage needed.
|
||||||
|
@ -255,7 +255,7 @@ are the only ones that can be accessed with a fixed negative offset.
|
||||||
The initial value of the allocated words is
|
The initial value of the allocated words is
|
||||||
not defined, but implementations that check for undefined
|
not defined, but implementations that check for undefined
|
||||||
values will probably initialize them with a
|
values will probably initialize them with a
|
||||||
special 'undefined' pattern, typically -32768.
|
special 'undefined' pattern, typically \-32768.
|
||||||
.A
|
.A
|
||||||
Fourth, any EM implementation is allowed to reserve a variable size
|
Fourth, any EM implementation is allowed to reserve a variable size
|
||||||
block beneath the local variables.
|
block beneath the local variables.
|
||||||
|
@ -297,7 +297,7 @@ This can be done with the aforementioned ASP instruction.
|
||||||
Each procedure frame is a separate fragment.
|
Each procedure frame is a separate fragment.
|
||||||
Because any fragment may be placed anywhere in memory,
|
Because any fragment may be placed anywhere in memory,
|
||||||
procedure frames need not be contiguous.
|
procedure frames need not be contiguous.
|
||||||
.DS
|
.Dr 47
|
||||||
|===============================|
|
|===============================|
|
||||||
| actual parameter n-1 |
|
| actual parameter n-1 |
|
||||||
|-------------------------------|
|
|-------------------------------|
|
||||||
|
@ -305,14 +305,14 @@ procedure frames need not be contiguous.
|
||||||
| . |
|
| . |
|
||||||
| . |
|
| . |
|
||||||
|-------------------------------|
|
|-------------------------------|
|
||||||
| actual parameter 0 | ( <- AB )
|
| actual parameter 0 | ( <\- AB )
|
||||||
|===============================|
|
|===============================|
|
||||||
|
|
||||||
|
|
||||||
|===============================|
|
|===============================|
|
||||||
|///////////////////////////////|
|
|///////////////////////////////|
|
||||||
|///// return status block /////|
|
|///// return status block /////|
|
||||||
|///////////////////////////////| <- LB
|
|///////////////////////////////| <\- LB
|
||||||
|===============================|
|
|===============================|
|
||||||
| |
|
| |
|
||||||
| local variables |
|
| local variables |
|
||||||
|
@ -340,11 +340,11 @@ procedure frames need not be contiguous.
|
||||||
| . |
|
| . |
|
||||||
| . |
|
| . |
|
||||||
|-------------------------------|
|
|-------------------------------|
|
||||||
| parameter 0 | <- SP
|
| parameter 0 | <\- SP
|
||||||
|===============================|
|
|===============================|
|
||||||
|
.Df
|
||||||
Figure 1. A sample procedure frame and parameters.
|
Figure 1. A sample procedure frame and parameters.
|
||||||
.DE
|
.De
|
||||||
.S2 "Heap data area"
|
.S2 "Heap data area"
|
||||||
The heap area starts empty, with HP
|
The heap area starts empty, with HP
|
||||||
pointing to the low end of it.
|
pointing to the low end of it.
|
||||||
|
|
209
doc/em/env.nr
Normal file
209
doc/em/env.nr
Normal file
|
@ -0,0 +1,209 @@
|
||||||
|
.SN 8
|
||||||
|
.VS 1 0
|
||||||
|
.BP
|
||||||
|
.S1 "ENVIRONMENT INTERACTIONS"
|
||||||
|
EM programs can interact with their environment in three ways.
|
||||||
|
Two, starting/stopping and monitor calls, are dealt with in this chapter.
|
||||||
|
The remaining way to interact, interrupts, will be treated
|
||||||
|
together with traps in chapter 9.
|
||||||
|
.S2 "Program starting and stopping"
|
||||||
|
EM user programs start with a call to a procedure called
|
||||||
|
m_a_i_n.
|
||||||
|
The assembler and backends look for the definition of a procedure
|
||||||
|
with this name in their input.
|
||||||
|
The call passes three parameters to the procedure.
|
||||||
|
The parameters are similar to the parameters supplied by the
|
||||||
|
UNIX
|
||||||
|
.FS
|
||||||
|
UNIX is a Trademark of Bell Laboratories.
|
||||||
|
.FE
|
||||||
|
operating system to C programs.
|
||||||
|
These parameters are often called
|
||||||
|
.BW argc ,
|
||||||
|
.B argv
|
||||||
|
and
|
||||||
|
.BW envp .
|
||||||
|
Argc is the parameter nearest to LB and is a wordsized integer.
|
||||||
|
The other two are pointers to the first element of an array of
|
||||||
|
string pointers.
|
||||||
|
.N
|
||||||
|
The
|
||||||
|
.B argv
|
||||||
|
array contains
|
||||||
|
.B argc
|
||||||
|
strings, the first of which contains the program call name.
|
||||||
|
The other strings in the
|
||||||
|
.B argv
|
||||||
|
array are the program parameters.
|
||||||
|
.P
|
||||||
|
The
|
||||||
|
.B envp
|
||||||
|
array contains strings in the form "name=string", where 'name'
|
||||||
|
is the name of an environment variable and string its value.
|
||||||
|
The
|
||||||
|
.B envp
|
||||||
|
is terminated by a zero pointer.
|
||||||
|
.P
|
||||||
|
An EM user program stops if the program returns from the first
|
||||||
|
invocation of m_a_i_n.
|
||||||
|
The contents of the function return area are used to procure a
|
||||||
|
wordsized program return code.
|
||||||
|
EM programs also stop when traps and interrupts occur that are
|
||||||
|
not caught and when the exit monitor call is executed.
|
||||||
|
.S2 "Input/Output and other monitor calls"
|
||||||
|
EM differs from most conventional machines in that it has high level i/o
|
||||||
|
instructions.
|
||||||
|
Typical instructions are OPEN FILE and READ FROM FILE instead
|
||||||
|
of low level instructions such as setting and clearing
|
||||||
|
bits in device registers.
|
||||||
|
By providing such high level i/o primitives, the task of implementing
|
||||||
|
EM on various non EM machines is made considerably easier.
|
||||||
|
.P
|
||||||
|
I/O is initiated by the MON instruction, which expects an iocode on top
|
||||||
|
of the stack.
|
||||||
|
Often there are also parameters which are pushed on the
|
||||||
|
stack in reverse order, that is: last
|
||||||
|
parameter first.
|
||||||
|
Some i/o functions also provide results, which are returned on the stack.
|
||||||
|
In the list of monitor calls we use several types of parameters and results,
|
||||||
|
these types consist of integers and unsigneds of varying sizes, but never
|
||||||
|
smaller than the wordsize, and the two pointer types.
|
||||||
|
.N 1
|
||||||
|
The names of the types used are:
|
||||||
|
.IS 4
|
||||||
|
.PS - 10
|
||||||
|
.PT int
|
||||||
|
an integer of wordsize
|
||||||
|
.PT int2
|
||||||
|
an integer whose size is the maximum of the wordsize and 2
|
||||||
|
bytes
|
||||||
|
.PT int4
|
||||||
|
an integer whose size is the maximum of the wordsize and 4
|
||||||
|
bytes
|
||||||
|
.PT intp
|
||||||
|
an integer with the size of a pointer
|
||||||
|
.PT uns2
|
||||||
|
an unsigned integer whose size is the maximum of the wordsize and 2
|
||||||
|
.PT unsp
|
||||||
|
an unsigned integer with the size of a pointer
|
||||||
|
.PT ptr
|
||||||
|
a pointer into data space
|
||||||
|
.PE 1
|
||||||
|
.IE 0
|
||||||
|
The table below lists the i/o codes with their results and
|
||||||
|
parameters.
|
||||||
|
This list is similar to the system calls of the UNIX Version 7
|
||||||
|
operating system.
|
||||||
|
.A
|
||||||
|
To execute a monitor call, proceed as follows:
|
||||||
|
.IS 2
|
||||||
|
.N 1
|
||||||
|
.PS a 4 "" )
|
||||||
|
.PT
|
||||||
|
Stack the parameters, in reverse order, last parameter first.
|
||||||
|
.PT
|
||||||
|
Push the monitor call number (iocode) onto the stack.
|
||||||
|
.PT
|
||||||
|
Execute the MON instruction.
|
||||||
|
.PE 1
|
||||||
|
.IE
|
||||||
|
An error code is present on the top of the stack after
|
||||||
|
execution of most monitor calls.
|
||||||
|
If this error code is zero, the call performed the action
|
||||||
|
requested and the results are available on top of the stack.
|
||||||
|
Non-zero error codes indicate a failure, in this case no
|
||||||
|
results are available and the error code has been pushed twice.
|
||||||
|
This construction enables programs to test for failure with a
|
||||||
|
single instruction (~TEQ or TNE~) and still find out the cause of
|
||||||
|
the failure.
|
||||||
|
The result name 'e' is reserved for the error code.
|
||||||
|
.N 1
|
||||||
|
List of monitor calls.
|
||||||
|
.DS B
|
||||||
|
.ta 2n 8n 16n 32n 48n
|
||||||
|
number name parameters results function
|
||||||
|
|
||||||
|
1 Exit status:int Terminate this process
|
||||||
|
2 Fork e,flag,pid:int Spawn new process
|
||||||
|
3 Read fildes:int;buf:ptr;nbytes:unsp
|
||||||
|
e:int;rbytes:unsp Read from file
|
||||||
|
4 Write fildes:int;buf:ptr;nbytes:unsp
|
||||||
|
e:int;wbytes:unsp Write on a file
|
||||||
|
5 Open string:ptr;flag:int
|
||||||
|
e,fildes:int Open file for read and/or write
|
||||||
|
6 Close fildes:int e:int Close a file
|
||||||
|
7 Wait e:int;status,pid:int2
|
||||||
|
Wait for child
|
||||||
|
8 Creat string:ptr;mode:int
|
||||||
|
e,fildes:int Create a new file
|
||||||
|
9 Link string1,string2:ptr
|
||||||
|
e:int Link to a file
|
||||||
|
10 Unlink string:ptr e:int Remove directory entry
|
||||||
|
12 Chdir string:ptr e:int Change default directory
|
||||||
|
14 Mknod string:ptr;mode,addr:int2
|
||||||
|
e:int Make a special file
|
||||||
|
15 Chmod string:ptr;mode:int2
|
||||||
|
e:int Change mode of file
|
||||||
|
16 Chown string:ptr;owner,group:int2
|
||||||
|
e:int Change owner/group of a file
|
||||||
|
18 Stat string,statbuf:ptr
|
||||||
|
e:int Get file status
|
||||||
|
19 Lseek fildes:int;off:int4;whence:int
|
||||||
|
e:int;oldoff:int4 Move read/write pointer
|
||||||
|
20 Getpid pid:int2 Get process identification
|
||||||
|
21 Mount special,string:ptr;rwflag:int
|
||||||
|
e:int Mount file system
|
||||||
|
22 Umount special:ptr e:int Unmount file system
|
||||||
|
23 Setuid userid:int2 e:int Set user ID
|
||||||
|
24 Getuid e_uid,r_uid:int2 Get user ID
|
||||||
|
25 Stime time:int4 e:int Set time and date
|
||||||
|
26 Ptrace request:int;pid:int2;addr:ptr;data:int
|
||||||
|
e,value:int Process trace
|
||||||
|
27 Alarm seconds:uns2 previous:uns2 Schedule signal
|
||||||
|
28 Fstat fildes:int;statbuf:ptr
|
||||||
|
e:int Get file status
|
||||||
|
29 Pause Stop until signal
|
||||||
|
30 Utime string,timep:ptr
|
||||||
|
e:int Set file times
|
||||||
|
33 Access string,mode:int e:int Determine file accessibility
|
||||||
|
34 Nice incr:int Set program priority
|
||||||
|
35 Ftime bufp:ptr e:int Get date and time
|
||||||
|
36 Sync Update filesystem
|
||||||
|
37 Kill pid:int2;sig:int
|
||||||
|
e:int Send signal to a process
|
||||||
|
41 Dup fildes,newfildes:int
|
||||||
|
e,fildes:int Duplicate a file descriptor
|
||||||
|
42 Pipe e,w_des,r_des:int Create a pipe
|
||||||
|
43 Times buffer:ptr Get process times
|
||||||
|
44 Profil buff:ptr;bufsiz,offset,scale:intp Execution time profile
|
||||||
|
46 Setgid gid:int2 e:int Set group ID
|
||||||
|
47 Getgid e_gid,r_gid:int Get group ID
|
||||||
|
48 Sigtrp trapno,signo:int
|
||||||
|
e,prevtrap:int See below
|
||||||
|
51 Acct file:ptr e:int Turn accounting on or off
|
||||||
|
53 Lock flag:int e:int Lock a process
|
||||||
|
54 Ioctl fildes,request:int;argp:ptr
|
||||||
|
e:int Control device
|
||||||
|
56 Mpxcall cmd:int;vec:ptr e:int Multiplexed file handling
|
||||||
|
59 Exece name,argv,envp:ptr
|
||||||
|
e:int Execute a file
|
||||||
|
60 Umask complmode:int2 oldmask:int2 Set file creation mode mask
|
||||||
|
61 Chroot string:ptr e:int Change root directory
|
||||||
|
.DE 1
|
||||||
|
Codes 0, 11, 13, 17, 31, 32, 38, 39, 40, 45, 49, 50, 52,
|
||||||
|
55, 57, 58, 62, and 63 are
|
||||||
|
not used.
|
||||||
|
.P
|
||||||
|
All monitor calls, except fork and sigtrp
|
||||||
|
are the same as the UNIX version 7 system calls.
|
||||||
|
.P
|
||||||
|
The sigtrp entry maps UNIX signals onto EM interrupts.
|
||||||
|
Normally, trapno is in the range 0 to 252.
|
||||||
|
In that case it requests that signal signo
|
||||||
|
will cause trap trapno to occur.
|
||||||
|
When given trap number \-2, default signal handling is reset, and when given
|
||||||
|
trap number \-3, the signal is ignored.
|
||||||
|
.P
|
||||||
|
The flag returned by fork is 1 in the child process and 0 in
|
||||||
|
the parent.
|
||||||
|
The pid returned is the process-id of the other process.
|
|
@ -90,11 +90,11 @@ few internal registers with specific functions as follows:
|
||||||
.TS
|
.TS
|
||||||
tab(:);
|
tab(:);
|
||||||
l 1 l l.
|
l 1 l l.
|
||||||
PC:-:Program Counter:Pointer to next instruction
|
PC:\-:Program Counter:Pointer to next instruction
|
||||||
LB:-:Local Base:Points to base of the local variables \
|
LB:\-:Local Base:Points to base of the local variables \
|
||||||
in the current procedure.
|
in the current procedure.
|
||||||
SP:-:Stack Pointer:Points to the highest occupied word on the stack.
|
SP:\-:Stack Pointer:Points to the highest occupied word on the stack.
|
||||||
HP:-:Heap Pointer:Points to the top of the heap area.
|
HP:\-:Heap Pointer:Points to the top of the heap area.
|
||||||
.TE 1
|
.TE 1
|
||||||
.IE
|
.IE
|
||||||
.A
|
.A
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
BEGIN { printf ".TS\nlw(6) lw(8) rw(3) rw(6) 14 lw(6) lw(8) rw(3) rw(6) 14 lw(6) lw(8) rw(3) rw(6).\n" }
|
BEGIN { printf(".TS\n");
|
||||||
NF == 4 { printf "%s\t%s\t%d\t%d",$1,$2,$3,$4 }
|
for (i = 0; i < 3; i++)
|
||||||
NF == 3 { printf "%s\t%s\t\t%d",$1,$2,$3 }
|
printf("lw(4) 0 lw(6) 0 rw(2) 0 rw(5) 8 ");
|
||||||
{ if ( NR%3 == 0 ) printf("\n") ; else printf("\t"); }
|
printf(".\n");
|
||||||
END { if ( NR%3 != 0 ) printf("\n")
|
}
|
||||||
printf ".TE\n" }
|
NF == 4 { printf "%s\t%s\t%d\t%d",$1,$2,$3,$4 }
|
||||||
|
NF == 3 { printf "%s\t%s\t\t%d",$1,$2,$3 }
|
||||||
|
{ if ( NR%3 == 0 ) printf("\n") ; else printf("\t"); }
|
||||||
|
END { if ( NR%3 != 0 ) printf("\n");
|
||||||
|
printf(".TE\n");
|
||||||
|
}
|
||||||
|
|
4691
doc/em/itables
4691
doc/em/itables
File diff suppressed because it is too large
Load diff
|
@ -21,7 +21,7 @@ two groups of 256 secondary opcodes each.
|
||||||
.A
|
.A
|
||||||
EM instructions without arguments have a single opcode assigned,
|
EM instructions without arguments have a single opcode assigned,
|
||||||
possibly escaped:
|
possibly escaped:
|
||||||
.DS
|
.Dr 14
|
||||||
|
|
||||||
|--------------|
|
|--------------|
|
||||||
| opcode |
|
| opcode |
|
||||||
|
@ -33,7 +33,7 @@ possibly escaped:
|
||||||
| escape | opcode |
|
| escape | opcode |
|
||||||
|--------------|--------------|
|
|--------------|--------------|
|
||||||
|
|
||||||
.DE
|
.De
|
||||||
The encoding for instructions with an argument is more complex.
|
The encoding for instructions with an argument is more complex.
|
||||||
Several instructions have an address from the global data area
|
Several instructions have an address from the global data area
|
||||||
as argument.
|
as argument.
|
||||||
|
@ -42,7 +42,7 @@ and negative arguments.
|
||||||
.N 1
|
.N 1
|
||||||
There is always an opcode that takes the next two bytes as argument,
|
There is always an opcode that takes the next two bytes as argument,
|
||||||
high byte first:
|
high byte first:
|
||||||
.DS
|
.Dr 14
|
||||||
|
|
||||||
|--------------|--------------|--------------|
|
|--------------|--------------|--------------|
|
||||||
| opcode | hibyte | lobyte |
|
| opcode | hibyte | lobyte |
|
||||||
|
@ -54,25 +54,25 @@ high byte first:
|
||||||
| escape | opcode | hibyte | lobyte |
|
| escape | opcode | hibyte | lobyte |
|
||||||
|--------------|--------------|--------------|--------------|
|
|--------------|--------------|--------------|--------------|
|
||||||
|
|
||||||
.DE
|
.De
|
||||||
.DS
|
|
||||||
An extra escape is provided for instructions with four or eight byte arguments.
|
An extra escape is provided for instructions with four or eight byte arguments.
|
||||||
|
.Dr 6
|
||||||
|
|
||||||
|--------------|--------------|--------------| |--------------|
|
|--------------|--------------|--------------| |--------------|
|
||||||
| ESCAPE | opcode | hibyte |...| lobyte |
|
| ESCAPE | opcode | hibyte |...| lobyte |
|
||||||
|--------------|--------------|--------------| |--------------|
|
|--------------|--------------|--------------| |--------------|
|
||||||
|
|
||||||
.DE
|
.De
|
||||||
For most instructions some argument values predominate.
|
For most instructions some argument values predominate.
|
||||||
The most frequent combinations of instruction and argument
|
The most frequent combinations of instruction and argument
|
||||||
will be encoded in a single byte, called a mini:
|
will be encoded in a single byte, called a mini:
|
||||||
.DS
|
.Dr 6
|
||||||
|
|
||||||
|---------------|
|
|---------------|
|
||||||
|opcode+argument| (mini)
|
|opcode+argument| (mini)
|
||||||
|---------------|
|
|---------------|
|
||||||
|
|
||||||
.DE
|
.De
|
||||||
The number of minis is restricted, because only
|
The number of minis is restricted, because only
|
||||||
254 primary opcodes are available.
|
254 primary opcodes are available.
|
||||||
Many instructions have the bulk of their arguments
|
Many instructions have the bulk of their arguments
|
||||||
|
@ -85,7 +85,7 @@ that combines the instruction and the high byte of the argument
|
||||||
into a single opcode.
|
into a single opcode.
|
||||||
These opcodes are called shorties.
|
These opcodes are called shorties.
|
||||||
Shorties may be escaped.
|
Shorties may be escaped.
|
||||||
.DS
|
.Dr 14
|
||||||
|
|
||||||
|--------------|--------------|
|
|--------------|--------------|
|
||||||
| opcode+high | lobyte | (shortie)
|
| opcode+high | lobyte | (shortie)
|
||||||
|
@ -97,7 +97,7 @@ Shorties may be escaped.
|
||||||
| escape | opcode+high | lobyte |
|
| escape | opcode+high | lobyte |
|
||||||
|--------------|--------------|--------------|
|
|--------------|--------------|--------------|
|
||||||
|
|
||||||
.DE
|
.De
|
||||||
Escaped shorties are useless if the normal encoding has a primary opcode.
|
Escaped shorties are useless if the normal encoding has a primary opcode.
|
||||||
Note that for some instruction-argument combinations
|
Note that for some instruction-argument combinations
|
||||||
several different encodings are available.
|
several different encodings are available.
|
||||||
|
@ -266,66 +266,66 @@ contain a null terminated ASCII string
|
||||||
.PE 1
|
.PE 1
|
||||||
.DE 0
|
.DE 0
|
||||||
.VS 1 1
|
.VS 1 1
|
||||||
.DS
|
.Dr 6
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
| 0 | n | repeat last initialization n times
|
| 0 | n | repeat last initialization n times
|
||||||
-------------------
|
-------------------
|
||||||
.DE
|
.De
|
||||||
.DS
|
.Dr 4
|
||||||
---------
|
---------
|
||||||
| 1 | m | m uninitialized words
|
| 1 | m | m uninitialized words
|
||||||
---------
|
---------
|
||||||
.DE
|
.De
|
||||||
.DS
|
.Dr 6
|
||||||
____________
|
____________
|
||||||
/ bytes \e
|
/ bytes \e
|
||||||
----------------- -----
|
----------------- -----
|
||||||
| 2 | m | b | b |...| b | m initialized bytes
|
| 2 | m | b | b |...| b | m initialized bytes
|
||||||
----------------- -----
|
----------------- -----
|
||||||
.DE
|
.De
|
||||||
.DS
|
.Dr 6
|
||||||
_________
|
_________
|
||||||
/ word \e
|
/ word \e
|
||||||
-----------------------
|
-----------------------
|
||||||
| 3 | m | w |... m initialized wordsized integers
|
| 3 | m | w |... m initialized wordsized integers
|
||||||
-----------------------
|
-----------------------
|
||||||
.DE
|
.De
|
||||||
.DS
|
.Dr 6
|
||||||
_________
|
_________
|
||||||
/ pointer \e
|
/ pointer \e
|
||||||
-----------------------
|
-----------------------
|
||||||
| 4 | m | p |... m initialized data pointers
|
| 4 | m | p |... m initialized data pointers
|
||||||
-----------------------
|
-----------------------
|
||||||
.DE
|
.De
|
||||||
.DS
|
.Dr 6
|
||||||
_________
|
_________
|
||||||
/ pointer \e
|
/ pointer \e
|
||||||
-----------------------
|
-----------------------
|
||||||
| 5 | m | p |... m initialized instruction pointers
|
| 5 | m | p |... m initialized instruction pointers
|
||||||
-----------------------
|
-----------------------
|
||||||
.DE
|
.De
|
||||||
.DS
|
.Dr 6
|
||||||
____________
|
____________
|
||||||
/ bytes \e
|
/ bytes \e
|
||||||
-------------------------
|
-------------------------
|
||||||
| 6 | m | b | b |...| b | initialized integer of size m
|
| 6 | m | b | b |...| b | initialized integer of size m
|
||||||
-------------------------
|
-------------------------
|
||||||
.DE
|
.De
|
||||||
.DS
|
.Dr 6
|
||||||
____________
|
____________
|
||||||
/ bytes \e
|
/ bytes \e
|
||||||
-------------------------
|
-------------------------
|
||||||
| 7 | m | b | b |...| b | initialized unsigned of size m
|
| 7 | m | b | b |...| b | initialized unsigned of size m
|
||||||
-------------------------
|
-------------------------
|
||||||
.DE
|
.De
|
||||||
.DS
|
.Dr 6
|
||||||
____________
|
____________
|
||||||
/ string \e
|
/ string \e
|
||||||
-------------------------
|
-------------------------
|
||||||
| 8 | m | s | initialized float of size m
|
| 8 | m | s | initialized float of size m
|
||||||
-------------------------
|
-------------------------
|
||||||
.DE 3
|
.De 3
|
||||||
.PS - 8
|
.PS - 8
|
||||||
.PT type~0:
|
.PT type~0:
|
||||||
If the last initialization initialized k bytes starting
|
If the last initialization initialized k bytes starting
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
.so /usr/lib/tmac/tmac.kun
|
.if n .so /usr/lib/tmac/tmac.kun
|
||||||
.SS 6
|
.if t .so /usr/lib/ditroff/tmac/tmac.kun
|
||||||
|
.SS 10
|
||||||
.RP
|
.RP
|
||||||
.PL 12i 11i
|
|
||||||
.LL 89
|
|
||||||
.MS T E
|
.MS T E
|
||||||
\!.TL '%'''
|
\!.TL '%'''
|
||||||
.ME
|
.ME
|
||||||
|
@ -14,3 +13,24 @@
|
||||||
.ME
|
.ME
|
||||||
.SM S1 B
|
.SM S1 B
|
||||||
.SM S2 B
|
.SM S2 B
|
||||||
|
.\" below are three simple macros to get the drawings right
|
||||||
|
.\" added by Dick Grune
|
||||||
|
.de Dr \" Drawing $1 (size)
|
||||||
|
.N 1
|
||||||
|
.NE \\$1
|
||||||
|
.NA
|
||||||
|
.cs 1 18 \" constant spacing
|
||||||
|
.lg 0 \" no ligatures
|
||||||
|
.ss 18 \" bug in troff
|
||||||
|
..
|
||||||
|
.de Df \" Drawing Footer
|
||||||
|
.br
|
||||||
|
.cs 1
|
||||||
|
.ss 12
|
||||||
|
.lg 1
|
||||||
|
..
|
||||||
|
.de De \" Drawing End $1 (lines)
|
||||||
|
.Df \" if it hasn't happened yet
|
||||||
|
.AD
|
||||||
|
.N \\$1
|
||||||
|
..
|
||||||
|
|
|
@ -14,46 +14,46 @@ with 64K bytes of address space.
|
||||||
Here we use a member of the EM family with 2-byte word and pointer
|
Here we use a member of the EM family with 2-byte word and pointer
|
||||||
size.
|
size.
|
||||||
The most straightforward layout is shown in figure 2.
|
The most straightforward layout is shown in figure 2.
|
||||||
.N 1
|
.Dr 40
|
||||||
.DS
|
65534 \-> |-------------------------------|
|
||||||
65534 -> |-------------------------------|
|
|
||||||
|///////////////////////////////|
|
|///////////////////////////////|
|
||||||
|//// unimplemented memory /////|
|
|//// unimplemented memory /////|
|
||||||
|///////////////////////////////|
|
|///////////////////////////////|
|
||||||
ML -> |-------------------------------|
|
ML \-> |-------------------------------|
|
||||||
| |
|
| |
|
||||||
| | <- LB
|
| | <\- LB
|
||||||
| stack and local area |
|
| stack and local area |
|
||||||
| |
|
| |
|
||||||
|-------------------------------| <- SP
|
|-------------------------------| <\- SP
|
||||||
|///////////////////////////////|
|
|///////////////////////////////|
|
||||||
|//////// inaccessible /////////|
|
|//////// inaccessible /////////|
|
||||||
|///////////////////////////////|
|
|///////////////////////////////|
|
||||||
|-------------------------------| <- HP
|
|-------------------------------| <\- HP
|
||||||
| |
|
| |
|
||||||
| heap area |
|
| heap area |
|
||||||
| |
|
| |
|
||||||
| |
|
| |
|
||||||
HB -> |-------------------------------|
|
HB \-> |-------------------------------|
|
||||||
| |
|
| |
|
||||||
| global data area |
|
| global data area |
|
||||||
| |
|
| |
|
||||||
EB -> |-------------------------------|
|
EB \-> |-------------------------------|
|
||||||
| |
|
| |
|
||||||
| program text | <- PC
|
| program text | <\- PC
|
||||||
| |
|
| |
|
||||||
| ( and tables ) |
|
| ( and tables ) |
|
||||||
| |
|
| |
|
||||||
| |
|
| |
|
||||||
PB -> |-------------------------------|
|
PB \-> |-------------------------------|
|
||||||
|///////////////////////////////|
|
|///////////////////////////////|
|
||||||
|////////// undefined //////////|
|
|////////// undefined //////////|
|
||||||
|///////////////////////////////|
|
|///////////////////////////////|
|
||||||
0 -> |-------------------------------|
|
0 \-> |-------------------------------|
|
||||||
|
.Df
|
||||||
Figure 2. Memory layout showing typical register
|
Figure 2. Memory layout showing typical register
|
||||||
positions during execution of an EM program.
|
positions during execution of an EM program.
|
||||||
.DE 2
|
.De
|
||||||
|
.N 1
|
||||||
The base registers for the various memory pieces can be stored
|
The base registers for the various memory pieces can be stored
|
||||||
in target machine registers or memory.
|
in target machine registers or memory.
|
||||||
.IS
|
.IS
|
||||||
|
@ -123,8 +123,7 @@ upside down, as shown in figure 3.
|
||||||
This is possible because the pointer format is explicitly undefined.
|
This is possible because the pointer format is explicitly undefined.
|
||||||
The first element of a word array will have a
|
The first element of a word array will have a
|
||||||
lower physical address than the second element.
|
lower physical address than the second element.
|
||||||
.N 2
|
.Dr 18
|
||||||
.DS
|
|
||||||
| | | |
|
| | | |
|
||||||
| EB=60 | | ^ |
|
| EB=60 | | ^ |
|
||||||
| | | | |
|
| | | | |
|
||||||
|
@ -140,18 +139,18 @@ lower physical address than the second element.
|
||||||
| | | |
|
| | | |
|
||||||
|
|
||||||
Type A Type B
|
Type A Type B
|
||||||
.sp 2
|
.Df
|
||||||
Figure 3. Two possible memory implementations.
|
Figure 3. Two possible memory implementations.
|
||||||
Numbers within the boxes are EM addresses.
|
Numbers within the boxes are EM addresses.
|
||||||
The other numbers are physical addresses.
|
The other numbers are physical addresses.
|
||||||
.DE 2
|
.De
|
||||||
.A 0 0
|
.A 0 0
|
||||||
So, we have two different EM memory implementations:
|
So, we have two different EM memory implementations:
|
||||||
.IS
|
.IS
|
||||||
.PS - 4
|
.PS - 4
|
||||||
.PT A~-
|
.PT A~\-
|
||||||
stack downwards
|
stack downwards
|
||||||
.PT B~-
|
.PT B~\-
|
||||||
stack upwards
|
stack upwards
|
||||||
.PE
|
.PE
|
||||||
.IE
|
.IE
|
||||||
|
@ -188,7 +187,7 @@ ADP:3:pop:r0:pop:r0
|
||||||
::push:r0:push:r0
|
::push:r0:push:r0
|
||||||
|
|
||||||
LOI:1:pop:r0:pop:r0
|
LOI:1:pop:r0:pop:r0
|
||||||
::-::neg:r0
|
::\-::neg:r0
|
||||||
::clr:r1:clr:r1
|
::clr:r1:clr:r1
|
||||||
::bisb:eb(r0),r1:bisb:eb(r0),r1
|
::bisb:eb(r0),r1:bisb:eb(r0),r1
|
||||||
::push:r1:push:r1
|
::push:r1:push:r1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.po 0
|
.po 0
|
||||||
.TP 1
|
.TP 1
|
||||||
.ll 79
|
.ll 79n
|
||||||
.sp 15
|
.sp 15
|
||||||
.ce 4
|
.ce 4
|
||||||
DESCRIPTION OF A MACHINE
|
DESCRIPTION OF A MACHINE
|
||||||
|
|
171
doc/em/traps.nr
Normal file
171
doc/em/traps.nr
Normal file
|
@ -0,0 +1,171 @@
|
||||||
|
.SN 9
|
||||||
|
.VS 1 0
|
||||||
|
.BP
|
||||||
|
.S1 "TRAPS AND INTERRUPTS"
|
||||||
|
EM provides a means for the user program to catch all traps
|
||||||
|
generated by the program itself, the hardware, or external conditions.
|
||||||
|
This mechanism uses five instructions: LIM, SIM, SIG, TRP and RTT.
|
||||||
|
This section of the manual may be omitted on the first reading since it
|
||||||
|
presupposes knowledge of the EM instruction set.
|
||||||
|
.P
|
||||||
|
The action taken when a trap occures is determined by the value
|
||||||
|
of an internal EM trap register.
|
||||||
|
This register contains a pointer to a procedure.
|
||||||
|
Initially the pointer used is zero and all traps halt the
|
||||||
|
program with, hopefully, a useful message to the outside world.
|
||||||
|
The SIG instruction can be used to alter the trap register,
|
||||||
|
it pops a procedure pointer from the
|
||||||
|
stack into the trap register.
|
||||||
|
When a trap occurs after storing a nonzero value in the trap
|
||||||
|
register, the procedure pointed to by the trap register
|
||||||
|
is called with the trap number
|
||||||
|
as the only parameter (see below).
|
||||||
|
SIG returns the previous value of the trap register on the
|
||||||
|
stack.
|
||||||
|
Two consecutive SIGs are a no-op.
|
||||||
|
When a trap occurs, the trap register is reset to its initial
|
||||||
|
condition, to prevent recursive traps from hanging the machine up,
|
||||||
|
e.g. stack overflow in the stack overflow handling procedure.
|
||||||
|
.P
|
||||||
|
The runtime systems for some languages need to ignore some EM
|
||||||
|
traps.
|
||||||
|
EM offers a feature called the ignore mask.
|
||||||
|
It contains one bit for each of the lowest 16 trap numbers.
|
||||||
|
The bits are numbered 0 to 15, with the least significant bit
|
||||||
|
having number 0.
|
||||||
|
If a certain bit is 1 the corresponding trap never
|
||||||
|
occurs and processing simply continues.
|
||||||
|
The actions performed by the offending instruction are
|
||||||
|
described by the Pascal program in appendix A.
|
||||||
|
.N
|
||||||
|
If the bit is 0, traps are not ignored.
|
||||||
|
The instructions LIM and SIM allow copying and replacement of
|
||||||
|
the ignore mask.~
|
||||||
|
.P
|
||||||
|
The TRP instruction generates a trap, the trap number being found on the
|
||||||
|
stack.
|
||||||
|
This is, among other things,
|
||||||
|
useful for library procedures and runtime systems.
|
||||||
|
It can also be used by a low level trap procedure to pass the trap to a
|
||||||
|
higher level one (see example below).
|
||||||
|
.P
|
||||||
|
The RTT instruction returns from the trap procedure and continues after the
|
||||||
|
trap.
|
||||||
|
In the list below all traps marked with an asterisk ('*') are
|
||||||
|
considered to be fatal and it is explicitly undefined what happens if
|
||||||
|
you try to restart after the trap.
|
||||||
|
.P
|
||||||
|
The way a trap procedure is called is completely compatible
|
||||||
|
with normal calling conventions. The only way a trap procedure
|
||||||
|
differs from normal procedures is the return. It has to use RTT instead
|
||||||
|
of RET. This is necessary because the complete runtime status is saved on the
|
||||||
|
stack before calling the procedure and all this status has to be reloaded.
|
||||||
|
Error numbers are in the range 0 to 252.
|
||||||
|
The trap numbers are divided into three categories:
|
||||||
|
.IS 4
|
||||||
|
.N 1
|
||||||
|
.PS - 10
|
||||||
|
.PT ~~0\-~63
|
||||||
|
EM machine errors, e.g. illegal instruction.
|
||||||
|
.PS - 8
|
||||||
|
.PT ~0\-15
|
||||||
|
maskable
|
||||||
|
.PT 16\-63
|
||||||
|
not maskable
|
||||||
|
.PE
|
||||||
|
.PT ~64\-127
|
||||||
|
Reserved for use by compilers, run time systems, etc.
|
||||||
|
.PT 128\-252
|
||||||
|
Available for user programs.
|
||||||
|
.PE 1
|
||||||
|
.IE
|
||||||
|
EM machine errors are numbered as follows:
|
||||||
|
.DS I 5
|
||||||
|
.TS
|
||||||
|
tab(@);
|
||||||
|
n l l.
|
||||||
|
0@EARRAY@Array bound error
|
||||||
|
1@ERANGE@Range bound error
|
||||||
|
2@ESET@Set bound error
|
||||||
|
3@EIOVFL@Integer overflow
|
||||||
|
4@EFOVFL@Floating overflow
|
||||||
|
5@EFUNFL@Floating underflow
|
||||||
|
6@EIDIVZ@Divide by 0
|
||||||
|
7@EFDIVZ@Divide by 0.0
|
||||||
|
8@EIUND@Undefined integer
|
||||||
|
9@EFUND@Undefined float
|
||||||
|
10@ECONV@Conversion error
|
||||||
|
16*@ESTACK@Stack overflow
|
||||||
|
17*@EHEAP@Heap overflow
|
||||||
|
18*@EILLINS@Illegal instruction
|
||||||
|
19*@EODDZ@Illegal size argument
|
||||||
|
20*@ECASE@Case error
|
||||||
|
21*@EMEMFLT@Addressing non existent memory
|
||||||
|
22*@EBADPTR@Bad pointer used
|
||||||
|
23*@EBADPC@Program counter out of range
|
||||||
|
24@EBADLAE@Bad argument of LAE
|
||||||
|
25@EBADMON@Bad monitor call
|
||||||
|
26@EBADLIN@Argument of LIN too high
|
||||||
|
27@EBADGTO@GTO descriptor error
|
||||||
|
.TE
|
||||||
|
.DE 0
|
||||||
|
.P
|
||||||
|
As an example,
|
||||||
|
suppose a subprocedure has to be written to do a numeric
|
||||||
|
calculation.
|
||||||
|
When an overflow occurs the computation has to be stopped and
|
||||||
|
the higher level procedure must be resumed.
|
||||||
|
This can be programmed as follows using the mechanism described above:
|
||||||
|
.DS B
|
||||||
|
.ta 1n 24n
|
||||||
|
mes 2,2,2 ; set sizes
|
||||||
|
ersave
|
||||||
|
bss 2,0,0 ; Room to save previous value of trap procedure
|
||||||
|
msave
|
||||||
|
bss 2,0,0 ; Room to save previous value of trap mask
|
||||||
|
|
||||||
|
pro calcule,0 ; entry point
|
||||||
|
lxl 0 ; fill in non-local goto descriptor with LB
|
||||||
|
ste jmpbuf+4
|
||||||
|
lor 1 ; and SP
|
||||||
|
ste jmpbuf+2
|
||||||
|
lim ; get current ignore mask
|
||||||
|
ste msave ; save it
|
||||||
|
lim
|
||||||
|
loc 16 ; bit for EFOVFL
|
||||||
|
ior 2 ; set in mask
|
||||||
|
sim ; ignore EFOVFL from now on
|
||||||
|
lpi $catch ; load procedure identifier
|
||||||
|
sig ; catch wil get all traps now
|
||||||
|
ste ersave ; save previous trap procedure identifier
|
||||||
|
; perform calculation now, possibly generating overflow
|
||||||
|
1 ; label jumped to by catch procedure
|
||||||
|
loe ersave ; get old trap procedure
|
||||||
|
sig ; refer all following trap to old procedure
|
||||||
|
asp 2 ; remove result of sig
|
||||||
|
loe msave ; restore previous mask
|
||||||
|
sim ; done now
|
||||||
|
; load result of calculation
|
||||||
|
ret 2 ; return result
|
||||||
|
jmpbuf
|
||||||
|
con *1,0,0
|
||||||
|
end
|
||||||
|
.DE 0
|
||||||
|
.VS 1 1
|
||||||
|
.DS
|
||||||
|
Example of catch procedure
|
||||||
|
.ta 1n 24n
|
||||||
|
pro catch,0 ; Local procedure that must catch the overflow trap
|
||||||
|
lol 2 ; Load trap number
|
||||||
|
loc 4 ; check for overflow
|
||||||
|
bne *1 ; if other trap, call higher trap procedure
|
||||||
|
gto jmpbuf ; return to procedure calcule
|
||||||
|
1 ; other trap has occurred
|
||||||
|
loe ersave ; previous trap procedure
|
||||||
|
sig ; other procedure will get the traps now
|
||||||
|
asp 2 ; remove the result of sig
|
||||||
|
lol 2 ; stack trap number
|
||||||
|
trp ; call other trap procedure
|
||||||
|
rtt ; if other procedure returns, do the same
|
||||||
|
end
|
||||||
|
.DE
|
|
@ -33,7 +33,7 @@ restrictions imposed on the representation of the types used.
|
||||||
A number \fBn\fP used in these paragraphs indicates the size of
|
A number \fBn\fP used in these paragraphs indicates the size of
|
||||||
the object in \fIbits\fP.
|
the object in \fIbits\fP.
|
||||||
.S2 "Unsigned integers"
|
.S2 "Unsigned integers"
|
||||||
The range of unsigned integers is 0..2\v'-0.5m'\fBn\fP\v'0.5m'-1.
|
The range of unsigned integers is 0..2\v'-0.5m'\fBn\fP\v'0.5m'\-1.
|
||||||
A binary representation is assumed.
|
A binary representation is assumed.
|
||||||
The order of the bits within an object is knowingly left
|
The order of the bits within an object is knowingly left
|
||||||
unspecified.
|
unspecified.
|
||||||
|
@ -60,21 +60,22 @@ and expect a correct result.
|
||||||
We assume existence of at least single word unsigned arithmetic
|
We assume existence of at least single word unsigned arithmetic
|
||||||
in any implementation.
|
in any implementation.
|
||||||
.S2 "Signed Integers"
|
.S2 "Signed Integers"
|
||||||
The range of signed integers is -2\v'-0.5m'\fBn\fP-1\v'0.5m'~..~2\v'-0.5m'\fBn\fP-1\v'0.5m'-1,
|
The range of signed integers is
|
||||||
|
\-2\v'-0.5m'\fBn\fP\-1\v'0.5m'~..~2\v'-0.5m'\fBn\fP\-1\v'0.5m'\-1,
|
||||||
in other words the range of signed integers of \fBn\fP bits
|
in other words the range of signed integers of \fBn\fP bits
|
||||||
using two's complement arithmetic.
|
using two's complement arithmetic.
|
||||||
The representation is the same as for unsigned integers except
|
The representation is the same as for unsigned integers except the range
|
||||||
the range 2\v'-0.5m'\fBn\fP-1\v'0.5m'~..~2\v'-0.5m'\fBn\fP\v'0.5m'-1 is mapped on the
|
2\v'-0.5m'\fBn\fP\-1\v'0.5m'~..~2\v'-0.5m'\fBn\fP\v'0.5m'\-1 is mapped on the
|
||||||
range -2\v'-0.5m'\fBn\fP-1\v'0.5m'~..~-1.
|
range \-2\v'-0.5m'\fBn\fP\-1\v'0.5m'~..~\-1.
|
||||||
In other words, the most significant bit is used as sign bit.
|
In other words, the most significant bit is used as sign bit.
|
||||||
The convert instructions between signed and unsigned integers
|
The convert instructions between signed and unsigned integers
|
||||||
of the same size can be used to catch errors.
|
of the same size can be used to catch errors.
|
||||||
.A
|
.A
|
||||||
The value -2\v'-0.5m'\fBn\fP-1\v'0.5m' is used for undefined
|
The value \-2\v'-0.5m'\fBn\fP\-1\v'0.5m' is used for undefined
|
||||||
signed integers.
|
signed integers.
|
||||||
EM implementations should trap when this value is used in an
|
EM implementations should trap when this value is used in an
|
||||||
operation on signed integers.
|
operation on signed integers.
|
||||||
The instruction mask, accessed with SIM and LIM -~see chapter 9~- ,
|
The instruction mask, accessed with SIM and LIM \-~see chapter 9~\- ,
|
||||||
can be used to disable such traps.
|
can be used to disable such traps.
|
||||||
.A
|
.A
|
||||||
We assume existence of at least single word signed arithmetic
|
We assume existence of at least single word signed arithmetic
|
||||||
|
@ -126,5 +127,5 @@ the value of the unsigned integer is the summation of the
|
||||||
Example: a 2-word bit set (wordsize 2) containing the
|
Example: a 2-word bit set (wordsize 2) containing the
|
||||||
elements 1, 6, 8, 15, 18, 21, 27 and 28 is composed of two
|
elements 1, 6, 8, 15, 18, 21, 27 and 28 is composed of two
|
||||||
integers, e.g. at addresses 40 and 42.
|
integers, e.g. at addresses 40 and 42.
|
||||||
The word at 40 contains the value 33090 (or~-32446),
|
The word at 40 contains the value 33090 (or~\-32446),
|
||||||
the word at 42 contains the value 6180.
|
the word at 42 contains the value 6180.
|
||||||
|
|
Loading…
Reference in a new issue