Professional Documents
Culture Documents
Loader PDF
Loader PDF
d a cum e n tat fa n :
henrik andersen
kurt jensen
b0 r q p s. !,< irk
0.1
CONTENTS
--------
--------
1.1 INTCODE
1.1 store and: registers
1.2 instruction formats
1.3 instructioncodes
1.5 executeoperations
2.1 ASSEMBLER
2.1 syntax - informal description
2.3 syntax - formal description
2.5 structure of assembler
2.9 output from assembler
2.12 workingtables
2.13 labeldeclarations and labe1references
2.16 switch- instruction
2.17 errormessages from assembler
3.1 LOADER
3.1 input
3.1 structure of the loader
3.2 the use of globals G.504-5ll
3.3 system
3.4 errormessages from loader
4.1 EMULATOR
4.1 ordre'cycl us
4.2 initialization of WA and WE
4.4 mainstore
4.5 read and 'tV'ri te
4.5 finish (X22)
INTCODE
STORE AND HEGISTETIS
-------------------
-------------------
address
10 0
INSTRUCTJONCODES
================
code mnell10nic
-------- comments
--------
-------- --------
010 Add A .- A + D
:BEFORE:
RFTER :
dcz,t~~ n+3
R
r- p
~~ J?-I-,:t, n I
'l<e:t.un1 Rdclte~
~
-
da-i~a- n+i
-1<.eiCl.H1 Rct~S5~
...
r-
~~CV f1
EXECUTEOPEHATIONS
=================
gg;; g~~g~~g~~gg
Xl Ao - loc(A)
0-
X2_ Ao- -A
o-
X] Ao° -- not A
x4 c o- lOC?+l)
0- Return from current routine or function.
po_ loco p)
0- Result of function is left in A.
X5 Ao - B
0- ~ A
x6 Ao-
o- B / A Integer division
X? Ao-
° - B rem A Rest after integer division.
X8 Ao - B + A.
0-
X9 Ao-
°- B - A
XlO Ao- B = A
0-
XII Ao- B f A
0-
x14 ·
Ao-
- B ) A
Xl5 Ao - B ~ A
0-
x16 ·
Ao- B lshift A
- B~ is shifted A times logical left
Xl? ·
Ao-
- B rshift A B is shifted A times logical right
nB lshift An is equivalent to liB rshift _An
X18 ·
Ao-
- B 1\ A
X19 ·
Ao-
- B V A
X20 Ao-
° - B ¥ A
X21 ·
Ao-
- B - A
X22 finish
i. • _
X23
n
label.default
condition.l
label.l.
condition.2
label.2
•
•
•
•
condition.n
label.n
n is a nonnegative integer.
Label.default, label.l •••• label.n are
labelvalues.
Condition.l •••••• condition.n are integers.
·••
i:f A = condition.n goto label.n
goto. label.def'aul t
A normal-instruction consits of
label
instructioncode
IPG-bits
address
I - indirect addressing
P add P-register to address
G - add G-register to address
<program) .. -- <segment>
+
<segment) <instruction)(Z-instruc>
*"
<labelpart> · .- <skip> «label; -«del in}> )
<skip> · .- C~l~.lm I !)~
<delim) · .- C~I1!£ I jJ+
<label) · .- {1,5 00}
~
<lPG-hit> · .- Cf I!: IQJ
<address) · .- {O, 64K-l} .1. .<label>
read ( )
----~$(mainloop
sw'itchon ch into
case L:
gato instruction
case X:
case D:
goto endcase
case c:
:t:
~
v 'case G:
~
0
G
"-l
~ case Y:
V)
case N:
instruction:
endcase:
$)mainloop repeat
If an L,S, •••• , X is recognizod it is a normal-instruction.
After thlS letter has been reco;?;nized these instructions are
handled together in Itinstruction u •
switchon ch into
$(switch2
case I:
case G:
default: test ch = L·
then
± addres specified as a
~ labelvalue
~
IJ)
.2£
$( address specified·as an
absolute address
case D: read ( )
S ,-[ i t c ho n c h in to
~(switchl
case C: read ()
case G: read()
collect globalnumber
collect labelnumber
$(SW
case D:
} declaration-address in dataarea
case C:
case L:
case X:
} declaration-address in codearea
where segmentblock is
mark 1-0
mark 0-1
size of codearea
size of dataarea
number of globals to initialize
number of referenced'labels
sumcheck
picture of codearea
picture of dataarea
globaltabe1
label tabe1
1. globalno
1. value
2. globalno
2. value
n. globalno
n. value
1. labe1dec
1. labelref
2. labeldec
2. labelref
n. labe1dec
n. labelref
Decarea and Refarea do exactly the same as Dectabarea and Ref tab-
area, but the former (dectabarea and reftabarea) is handling
userdefined labels, while decarea and refarea handles assemble~
generated labels '(see p 281~.Lpointer points to the first free
labelname in decarea and refarea.
bit 15
--.! ~
t.;. HFfRL< r-
(a..,) ( b) (c)
This page and the next shows how labels are handled.
The corresponding instructions could be:
J)}:CT
500
olZ 1 - - - - - - 1 L - -_ _ _ _ _ em I}./J~
78~ _ _ _ _--r
Ot..-_ _ _ _ ~
.- OL 78
3/z. 1--------,
7SL-_ _ _ _~
OL-_ _ _ _---,
GLDBFlR£
MRRK ~ G 81Z L 78
fJFlRK ~ GzoG L o/:b
(d)
Instruction X23 is a switch instruction. According to the intcode
discription it should be used as follows:
X23
Dn
DL label.default
D cond:.l
DL label .• l
D cond.2
DL label.2
..
D cond.n
DL label.n
kept in
codearea { X23
DL nn "~I-------- __ please notice:
nn:Dn this DL-instruction
D label '.defaul t
is created by the
D cond.l assembler and kept
kept in
D label.l in codearea
dataarea
D cond.n
D label.n
TOO NANY SWITCHES the segment has more than 100 switch-
instructions (X23 -instructions)
LOADEH
INPUT
-----
The loader takes ~nput from the assembler.
The syntax ~s descr~bed on pages 2.9 through 2,.11 and page 2.13.
presentat~on
newtape:
§ (while
read header
sumcheck
§ )1vh~l e
go ()
G.5ll 1Vlimi t}
G.510 PeO -variable (program's limits and
G.509 entrypoint)
G.508 "tvlimi t}
G.507 pO -constant (system's limits and
G.506 e. entrypoint)
G.505 e -loader's entrypoint
G.504 C -assembler's entrypoint
QQil initializes G.5ll, G.5l0 and G.509 "tvith the loaded program's
wlimit (cbase-l), pO (dtop) and C (entrypoint).
select(consoletable)
again:
1.... rites(It*N assembler:a or loader:l 1")
help.: = input
~ goto again
7. Increment C (programcounter)
8. Decode instructioncode
11. goto 1.
INITIALIZATION OF WA AND WB
===========================
0: ERROR address Xl
1 : address X2 address X3
2: address x4 address X5
0: BASE
1 : 1>J"L II-I IT
2: PO
3: ERROR
4: FLAG
5: B
6: A
7: C
8: D
9: P
10: G
11:
12: INPUT
13: OUTPUT
14: CS
l"S : LIMIT
LIMIT
codearea
segment 1
codearea
segment 2
codearea
segment n
1~~~~~~~--lvLIMIT
runtime
stack
PO
dataarea
segment n
dataarea
segment 2
dataarea
segment 1
global
vector
dump
areal
BASE 0
4.5