1
0
mirror of https://github.com/DoctorWkt/pdp7-unix.git synced 2026-04-20 01:33:28 +00:00
This commit is contained in:
Josh Dersch
2016-02-26 14:18:27 -08:00
28 changed files with 7405 additions and 198 deletions

View File

@@ -3,3 +3,7 @@ to cache my Github username
git config --global user.name "Warren Toomey"
git config --global user.email wkt@tuhs.org
To bring your own ocal repository up to date with Github:
git fetch origin
git merge origin/master

4
scans/Makefile Normal file
View File

@@ -0,0 +1,4 @@
AS7=../tools/as7
system:
$(AS7) s?.s sop.s > output

View File

@@ -1,4 +1,4 @@
This area contains the OCR'd version of the PDP-7 scans that are at
This area contains the OCR'd versions of the PDP-7 scans that are at
http://www.tuhs.org/Archive/PDP-11/Distributions/research/McIlroy_v0/0*.pdf
The files should be unaltered versions of the scanned pages.
@@ -6,5 +6,30 @@ For modified versions of these files, look in src/cmds and src/sys.
Details of the files:
s1.s: pages 2-3 of 01-s1.pdf, incomplete and with some cruft at the end
s1.s: pages 2-5 of 01-s1.pdf
s2.s: pages 7-12 of 01-s1.pdf
s3.s: pages 14-19 of 01-s1.pdf
s4.s: pages 21-26 of 01-s1.pdf
s5.s: pages 28-32 of 01-s1.pdf
s6.s: pages 34-38 of 01-s1.pdf
s7.s: pages 41-46 of 01-s1.pdf
s8.s: pages 48-51 of 01-s1.pdf
s9.s: pages 53-54 of 01-s1.pdf
sop.s pages 62-63 of 01-s1.pdf
sx.s: temp additional symbol defns
maksys.s: page 64 of 01-s1.pdf
trysys.s: page 65 of 01-s1.pdf
bc.s: pages 7-11 of 06-5-12.pdf
bi.s: pages 12-19 of 06-5-12.pdf
bl.s: pages 3-6 of 06-5-12.pdf
cas.s: pages 1-17 of 04-cas.pdf
cat.c: pages 21-23 of 06-5-12.pdf
ind.b: page 2 of 08-rest.pdf
lease.b: page 4 of 08-rest.pdf
as.s: pages 32-48 of 05-1-4.pdf
ed1.s: pages 7-20 of 08-rest.pdf
ed2.s: pages 21-29 of 08-rest.pdf

980
scans/as.s Normal file
View File

@@ -0,0 +1,980 @@
" as
jms init1
assm1:
lac eofflg
sza
jmp assm2
lac passno
sza
jmp finis
jms init2
assm2:
jms gchar
sad d4
jmp assm1
sad d5
jmp assm1
lac char
dac savchr
jms gpair
lac rator
jms betwen; d1; d6
jmp assm3
jms expr
lac passno
sza
jms process
isz dot+1
nop
lac dot+1
and o17777
sad dot+1
jmp assm1
jms error; >>
dzm dot+1
jmp assm1
assm3:
lac rand
sad d2
jmp assm4
sza
jmp assm6
lac rator
sza
jmp assm6
lac rand+1
jms betwen; dm1; d10
jmp assm6
dac name
tad fbxp
dac lvrand
lac i lvrand
dac name+1
isz i lvrand
lac o146
dac name+2
dzm name+3
jms tlookup
-1
dac fbflg
assm4:
lac rand+1
tad d4
dac lvrand
lac rator
sza
jmp assm5
lac dot
dac r
lac dot+1
dac r+1
jmp 1f
assm5:
jms gpair
jms expr
1:
lac r
dac i lvrand
isz lvrand
lac r+1
dac i lvrand
lac fbflg
sna
jmp assm1
dzm fbflg
dzm name+1
lac o142
dac name+2
jms lookup
jmp assm4
assm6:
jms error; x>
jmp assm1
init1: 0
lac d1
sys write; 1f; 2f-1f
dzm passno
lac o56040
dac dot-4
lac o56056
dac cmflx-4
lac o40040
dac dot-3
dac dot-2
dac dot-1
dac cmflx-3
dac cmflx-2
dac cmflx-1
dzm iof
jms init
jmp i init1
1:
0111012
2:
init2: 0
lac d1
dac passno
sys write; 1f; 2f-1f
jms init
lac o17
sys creat; 2f
dac bfo
sys open; 2f; 0
dac bfi
dzm bufadd
jms copyz; buf; 64
jmp i init2
1:
0111111;012000
2:
0141056;0157165;0164040;040040
init: 0
lac i 017777
dac narg
lac 017777
tad d1
dac fname
-1
dac eofflg
jms ioinit
dzm savchr
dzm comflg
lac d1
dac dot
dzm dot+1
dzm cmflx
lac d4096
dac cmflx+1
dzm fbflg
jms copyz; fbxp: fbx; 10
jmp i init
finis:
lac iof
sys close
jms bufwr
lac bfi
sys close
lac bfo
sys close
-1
tad namsiz
cma
rcl
dac char
rcl
tad char
dac 1f
lac o17
sys creat; n.out
dac bfi
sys write; namlst; 1: 0
lac bfi
sys close
sys exit
n.out:
0156056;0157165;0164040;040040
process: 0
lac dot+1
dac lvrand
lac dot
sad d3
jmp proc4
sza
jmp proc1
-1
tad cmflx+1
cma
tad lvrand
dac lvrand
proc1:
lac lvrand
spa
jmp proc4
and o17700
sad bufadd
jmp proc2
jms bufwr
jms copyz; buf; 64
lac lyrand
and o17700
dac bufadd
dac 1f
lac bfi
sys seek; 1: 0; 0
spa
jmp proc2
lac bfi
sys read; buf; 64
proc2:
lac lyrand
and o77
jms betwen; dm1; maxsto
dac maxsto
tad bufp
dac lvrand
lac r
sna
jmp proc3
sad d3
jmp proc5
lac cmflx+1
tad r+1
dac r+1
proc3:
lac r+1
dac i lvrand
jmp i process
proc4:
jms error; .>
lac d1
dac dot
dzm dot+1
jmp skip
proc5:
jms error; u>
jmp proc3
bufwr: 0
lac bfo
sys seek; bufadd: 0; 0
isz maxsto
lac bfo
sys write; bufp: buf; maxstp: -1
-1
dac maxsto
jmp i bufwr
Xnumber: 0
dac 3f
lac d1000
dac 2f
1:
lac 3f
cll
idiv; 2: 0
dac 3f
lacq
tad o60
dac i 8
iac 2b
cll
idiv; 10
lacq
dac 2b
sza
jmp 1b
jmp i number
3: 0
getsc: 0
lac i getsc
dac sctalp
isz getsc
lac i sctalp
dac sctal
add o400000
dac i sctalp
ral
lac i sctal
szl
lrss 9
and o177
jmp i getsc
putsc: 0
and o177
lmq
lac i putsc
dac sctalp
isz putsc
lac i sctalp
dac sctal
add o400000
dac i sctalp
sma cla
jmp 1f
llss 27
dac i sctal
lrss 9
jmp i putsc
1:
lac i sctal
omq
dac i sctal
lacq
jmp i putsc
sctalp: 0
sctal: 0
betwen: 0
dac 2f
lac i betwen
dac 3f
isz betwen
lac i 3f
cma
tad 2f
spa
jmp 2f
lac i betwen
dac 3f
isz betwen
lac i 3f
cma
tad d1
tad 2f
spa
1:
isz betwen
lac 2f
jmp i betwen
2: 0
3: 0
copyz: 0
-1
tad i copyz
dac 8
isz copyz
lac i copyz
cma
tad d1
dac 2f
isz copyz
1:
dzm i 8
isz 2f
jmp 1b
jmp i copyz
2: 0
error: 0
lac passno
sza
jmp 1f
isz error
jmp i error
1:
-1
tad mesp
dac 8
lac i error
dac i 8
lac o40
dac i 8
lac rator
sad d5
jmp 1f
lac savchr
sad o12
jmp 1f
lac lineno
jmp 2f
1:
-1
tad lineno
2:
jms number
lac o12
dac i 8
-2
tad mesp
cma
tad 8
dac 1f
lac d1
sys write; mesp: mes; 1: 0
isz error
jmp i error
skip:
lac rator
sad d5
jmp assm1
1:
jms gchar
sad d5
jmp assm1
jmp 1b
ioinit: 0
jms copyz; iobuf; 64
lac iof
sys read; iobufp: iobuf; 64
sna
jms nextfil
lac iobufp
dac tal
-129
dac talc
jmp i ioinit
nextfil: 0
lac d1
dac lineno
lac iof
sza
sys close
nf1:
lac narg
sad d4
skp
jmp 1f
dzm eofflg
jmp i nextfil
1:
tad dm4
dac narg
lac fname
tad d4
dac fname
sys open; frame: 0; 0
dac iof
sma
lac passno
sna
jmp nextfil i
lac fname
dac 1f
lac d1
sys write; 1; 0; 4
lac iof
sma
jmp 1f
lac d1
sys write; emes; 2
sys exit
1:
lac d1
sys write; emes+1; 1
jmp i nextfil
emes:
040077;012000
gchar: 0
lac savchr
dzm savchr
sza
jmp gch3
lac eofflg
sza
jmp 1f
lac o12
jmp gch3
1:
isz talc
skp
jms ioinit
jms getsc; tal
sna
jmp gchar+1
sad o177
jmp gchar+1
sad o12
skp
jmp 1f
dzm comflc
isz lineno
1:
sad o42
dac comflc
dac char
lac comflc
sza
jmp gchar+1
lac char
gch3:
dac char
jms betwn; d0; o200
cla
tad lactab
dac .+1
lac 0
jmp i gchar
gsymb: 0
jms gchar
dac rator
tad jmpsw1
dac 1f
lac char
sad o74
jmp lqot
dac namc
jms gchar
lac char
sad o76
jmp rqot
dac savchr
lac namc
dac char
1:
jmp 0
jmpsw1:
jmp .+1
jmp i gsymb
jmp i gsymb
jmp i gsymb
jmp i gsymb
jmp gs1
jmp i gsymb
jmp gs2
jmp gs3
badchr:
jms error; g>
1:
jms gchar
lac char
sad o12
skp
jmp 1b
dac savchr
jmp gsymb+1
lqot:
jms gchar
lac o40
dac savchr
lac char
alss 9
jmp 1f
rqot:
lac namc
1:
dac rand+1
lac d7
dac rator
jmp i gsymb
gs1:
jms gchar
sad d4
jmp gs1
lac char
dac savchr
jmp i gsymb
gs2:
lac namep
dac tal1
-7
dac tal1c
lac char
jms putsc; tal1
gnam1:
jms gchar
jms betwen; d5; d8
jmp gnam3
lac char
jms putsc; tal1
isz tal1c
jmp gnam1
gnam2:
jms gchar
jms betwen; d5; d8
skp
jmp gnam2
lac char
dac savchr
jms lookup
jmp i gsymb
gnam3:
lac char
dac savchr
1:
lac o40
jms putsc; tal1
isz tal1c
jmp 1b
jms lookup
jmp i gsymb
gs3:
dzm rand+1
lac char
sad o60
jmp 1f
lac d10
jmp 2f
1:
lac d8
2:
dac num2
num1:
lac rand+1
cll
mul
num2: 0
lacq
tad char
tad dm48
dac rand+1
jms gchar
sad d7
jmp num1
lac char
dac savchr
lac rand+1
jms betwen; dm1; d10
jmp i gsymb
dac name
tad fbxp
dac name+1
lac i name+1
dac name+1
lac savchr
sad o146
jmp 1f
sad o142
skp
jmp i gsymb
dzm name+1
1:
dac name+2
dzm name+3
lac d6
dac rator
jms lookup
dzm savchr
jmp i gsymb
tlookup: 0
jmp 1f
lookup: 0
dzm tlookup
1:
-1
tad namlstp
dac 8
lac namsiz
dac namc
lu1:
lac i 8
sad name
jmp 1f
lac d5
lu2:
tad 8
dac 8
isz namc
jmp lu1
lac tlookup
sna
jmp 2f
lac fnamep
dac rand+1
jmp i tlookup
2:
lac name
dac i 8
lac 8
dac rand+1
lac name+1
dac i 8
lac name+2
dac i 8
lac name+3
dac i 8
lac d3
dac i 8
dzm i 8
-1
tad namsiz
dac namsiz
jmp i lookup
1:
lac i 8
sad name+1
jmp 1f
lac d4
jmp lu2
1:
lac i 8
sad name+2
jmp 1f
lac d3
jmp lu2
1:
lac i 8
sad name+3
jmp 1f
lac d2
jmp lu2
1:
-3
tad 8
dac rand+1
lac tlookup
sza
jmp i tlookup
jmp i lookup
namep: name
gpair: 0
jms gsymb
lac rator
sad d4
jmp gpair+1
jms betwen; dm1; d6
jmp gp1
dzm rand
dzm rand+1
jmp i gpair
gp1:
sad d7
lac d4
tad dm4
dac rand
jms gsymb
lac rator
sad d4
jmp gp2
jms betwen; dm1; d6
skp
jmp i gpair
jms error; x>
jmp skip
gp2:
jms gchar
jms betwen; d5; d8
jmp gp3
lac char
dac savchr
jmp i gpair
gp3:
lac char
dac savchr
jms gsymb
jmp i gpair
expr: 0
jms grand
-1
dac srand
exp5:
lac rand
dac r
lac rand+1
dac r+1
exp1:
lac rator
jms betwen; d1; d5
jmp exp3
dac orator
jms gpair
jms grand
lac orator
sad d4
jmp exp2
jms oper; rand
jmp exp1
exp2:
jms pickup
lac r
dac srand
lac r+1
dac srand+1
jmp expb
exp3:
sad d5
jmp exp4
jms error; x>
smp skip
exp4:
jms pickup
jmp i expr
pickup: 0
lac srand
spa
jmp i pickup
lac d4
jms oper; srand
jmp i pickup
grand: 0
lac rand
sad d2
skp
jmp i grand
lac rand+1
tad d4
dac rand+1
lac i rand+1
dac rand
isz rand+1
lac i rand+1
dac rand+1
jmp i grand
oper: 0
tad opsw
dac oper1
-1
tad i oper
dac 8
isz oper
lac r
sad d3
jmp oper2
lac i 8
sad d3
jmp oper2
oper1:
jmp 0
opsw:
jmp .-1
jmp oplus
jmp ominus
tad r
dac r
lac r+1
lmq
lac i 8
omq
jmp oret
oplus:
tad r
dac r
lac r+1
tad i 8
jmp oret
ominus:
cma
tad d1
tad r
dac r
-1
tad i 8
cma
tad r+1
oret:
dac r+1
lac r
jms betwen; dm1; d2
skp
jmp i oper
jms error; r>
lac d1
dac r
jmp i oper
oper2:
dac r
dzm r+1
jmp i oper
d0: 0
d1: 1
d4096: 4096
d2: 2
d3: 3
d4: 4
d5: 5
d6: 6
d7: 7
d8: 8
o12: d10: 10
dm1: -1
o40: 040
o60: 060
dm48: -48
o400000: 0400000
o177: 0177
dm4: -4
o200: 0200
o42: 042
o142: 0142
o40040: 040040
o56056: 056056
o56040: 056040
o146: 0146
o17777: 017777
d1000: 1000
o17: 017
o17700: 017700
o77: 077
o74: 074
o76: 076
namsiz: -2
namistp: namlst
fnamep: fakename
lactab: lac .+1
8;8;8;8;8;8;8;8
8;4;5;8;8;8;8;8
8;8;8;8;8;8;8;8
8;8;8;8;8;8;8;8
4;8;8;8;8;8;8;8
8;8;6;2;4;3;6;8
7;7;7;7;7;7;7;7
7;7;0;5;8;1;8;8
8;6;6;6;6;6;6;6
6;6;6;6;6;6;6;6
6;6;6;6;6;6;6;6
6;6;6;8;8;8;8;8
8;6;6;6;6;6;6;6
6;6;6;6;6;6;6;6
6;6;6;6;6;6;6;6
6;6;6;8;8;8;8;8
fbflg: .=.+1
tal: .=.+1
talc: .=.+1
tal1: .=.+1
tal1c: .=.+1
narg: .=.+1
lvrand: .=.+1
eofflg: .=.+1
namc: .=.+1
passno: .=.+1
char: .=.+1
savchr: .=.+1
comflg: .=.+1
rator: .=.+1
orator: .=.+1
rand: .=.+2
srand: .=.+2
r: .=.+2
name: .=.+4
buf: .=.+64
iobuf: .=.+64
fbx: .=.+10
mes: .=.+20
iof: .=.+1
bfi: .=.+1
bfo: .=.+1
lineno: .=.+1
fakename: .=.+6
namlst:
.=.+4
dot:
.=.+6
cmflx:

288
scans/bc.s Normal file
View File

@@ -0,0 +1,288 @@
" bc
jmp start
rinit:
jms initio
jmp .+1 i
initio: 0
lac inter-1
dac fetch
jmp rinit
jms inter
inter: 0
las
and o17
sza
jms trace
lac pc i
dac instr
lac pc
and o10000
sna
jmp badpc
lac sp
and o17700
sad o17700
jmp badsp
and o10000
sna
jmp badsp
lac instr
sad insasg
skp
jmp inter i
-4
tad sp
dac t1
lac t1 i
and o10000
sna
jmp badasgn
lac instr
jmp inter i
trace: 0
and d1
sza
jms dtrace
las
and d2
sza
jms ddisp
las
and d4
sza
jms histog
las
and d8
sza
jmp stop
jmp trace i
itrace: 0
lac pc
dac 8
lac 8 i
dac instr
lac 8
jms octal; -4
law 040
jms putc
lac instr
cll; lrs 14
tad lacop
dac .+1
lac ..
jms putc
law 040
jms putc
lac instr
jms octal; -4
lac instr
sad inslitr
skp
jmp 1f
law 040
jms putc
lac 8 i
jms octal; -6
1:
law 012
jms putc
jms flush
jmp dtrace i
ddisp: 0
jms dspinit
lac dspbp
dac 8
lac dp
sad olddp
skp
jms dspblk
lac pc
jms dspnt
lac sp
jms dspnt
lac lastv
jms dspnt
-1
dac B i
lac pbs i
sza
jmp .-2
jmp ddisp i
dspblk: 0
lac dspbuf
dac 8
lac dp
dac t1
dzm t2
1:
lac t1
sna
jmp 1f
lac o216000 " dx -20
dac 8 i
lac t2
tad o20
dac t2
lac t1
tad d1
dac t3
lac t3 i
jms dspnt
lac t1 i
dac t1
jmp 1b
1:
lac o160020 " sx 20
tad t2
dac dspbuf i
dac 8 i
lac 8
dac dspbp
jmp dspblk i
dspnt: 0
and o7777
lrss 2
xor o164000 " sy 0
dac 8 i
lac o17010
dac 8 i
jmp dspnt i
dspinit: 0
-1
tad dspinit
dac dspinit
-300
tad lastv
dac lastv
dac dspbuf
-1
dac dspinit i
dac dspbuf i
dzm olddp
lac dspbuf
sys capt
law 13
sys sysloc
dac pbs
jmp dspinit i
histog: 0
jms hisinit
lac pc
lrs 6
and o77
tad histbuf
dac t1
isz t1 i
jmp histog i
jmp .
hisinit: 0
-1
tad hisinit
dac hisinit
-1
dac hisinit i
-64
dac t1
tad lastv
dac lastv
dac histbuf
tad dm1
dac 8
1:
dsm 8 i
isz t1
jmp 1b
jmp hisinit i
histbuf: 0
olddp: 0
dspbuf: 0
dspbp: 0
instr: 0
obs: 0
inslitr: n 5
insasg: b 1
o17: 017
d8: 8
o77: 077
o10000: 010000
d5: 5
o60: 060
o7777: 07777
o216000: 0216000
o160020: 0160020
o20: 020
o164000: 0164000
o17010: 017010
o17700: 017700
d2: 2
lacop: lac .
a>;b>;c>;f>;n>;s>;t>;u>;x>;y>
badpc:
jms flush
lac d1
sys write; mpc; mpcs
jmp stop
badsp:
jms flush
lac d1
sys write; msp; msps
jmp stop
badasgn:
jms flush
lac d1
sys write; mas; mass
jmp stop
mpc:
012;<pc>;012
mpcs = .-mpc
msp:
012;<sp>;012
msps = .-msp
mas:
012;<as>;012
mass = .-mas
octal: 0
lmq
lac d5
tad octal i
cma
dac 2f
sna
jmp 3f
1:
llss 3
isz 2f
jmp 1b
3:
lac octal i
dac 2f
lacq
dac 2f+1
1:
lac 2f+1
lmq
ecla llss 3
tad o60
jms putc
lac 2f+1
alss 3
dac 2f+1
isz 2f
jmp 1b
isz octal
jmp octal i
2: 0;0

433
scans/bi.s Normal file
View File

@@ -0,0 +1,433 @@
" bi
start:
jms initio
-1
tad .main
dac pc
fetch:
lac pc i
imq
and o17777
dac addr
ecla lls 4
tad .+3
dac .+1
jmp .. i
jmp . i
autop; binop; consop; ifop; etcop; setop; traop
unaop; extop; aryop
ifop:
-2
tad sp
dac sp
lac sp i
dac t1
lac t1 i
sza
jmp fetch
-1
tad addr i
dac pc
jmp fetch
autop:
lac addr
tad dp
dac sp i
isz sp
isz sp
jmp fetch
binop:
-2
tad sp
dac sp
tad dm1
dac t4
tad dm1
dac t3
lac t3 i
dac t1
lac sp i
dac t2
lac t4
dac t3 i
lac addr
tad .+3
dac .+1
jmp .. i
jmp . i
basg; bor; band; beq; bne; ble; blt; bge; bgt; brsh; blsh
badd; bmin; bmod; bmul; bdiv
basg:
lac t2 i
dac t1 i
dac t4 i
jmp fetch
bor:
lac t1 i
lmq
lac t2 i
omq
dac t4 i
jmp fetch
band:
lac t2 i
and t2 i
dac t4 i
jmp fetch
beq:
lac t1 i
xor t2 i
sna cla
lac d1
dac t4 i
jmp fetch
bne:
lac t1 i
xor t2 i
sza
lac d1
dac t4 i
jmp fetch
ble:
lac t2 i
cma
tad t1 i
spa cla
lac d1
dac t4 i
jmp fetch
blt:
lac t1 i
cma
tad t2 i
sma cla
lac d1
dac t4 i
jmp fetch
bge:
lac t1 i
cma
tad t2 i
spa cla
lac d1
dac t4 i
jmp fetch
bgt:
lac t2 i
cma
tad t1 i
sma cla
lac d1
dac t4 i
jmp fetch
brsh:
blsh:
hlt
badd:
lac t1 i
tad t2 i
dac t4 i
jmp fetch
bmin:
lac t1 i
cma
tad t2 i
cma
dac t4 i
jmp fetch
bmod:
lac t2 i
dac .+4
lac t1 i
cll; idiv; ..
dac t4 i
jmp fetch
bmul:
lac t2 i
dac .+4
lac t1 i
cll; mul; ..
lacq
dac t4 i
jmp fetch
bdiv:
lac t2 i
dac .+4
lac t1 i
cll; idiv; ..
lacq
dac t4 i
jmp fetch
consop:
lac sp
tad d1
dac sp i
isz sp
iac addr
dac sp i
isz sp
jmp fetch
etcop:
lac addr
tad .+3
dac .+1
jmp .. i
jmp . i
mcall; mark; call; vector; litrl; goto; retrn; escp
mcall:
-2
tad sp
dac t1
lac t1 i
dac t2
-1
tad t2 i
imq
lac dp
dac t1 i
lac t1
dac dp
isz t1
iac pc
dac t1 i
lacq
dac pc
jmp fetch
mark:
-1
tad sp
dac t2
tad dm1
dac t1
lac t1 i
dac t3
lac t3 i
dac t2 i
lac ap
dac t1 i
lac t1
dac ap
jmp fetch
call:
lac ap
tad d1
dac 8
dac 9
1:
lac 8 i
dac t1
lac t1 i
dac 9 i
isz 8
-1
tad sp
sad B
skp
jmp 1b
lac ap i
img
lac dp
dac ap i
lac ap
dac dp
isz ap
-1
tad ap i
dac t1
lac pc
dac ap i
lacq
dac ap
lac t1
dac pc
jmp fetch
vector:
-2
tad sp
dac sp
tad dm2
dac t1
lac sp i
dac t2
lac t1 i
dac t3
lac t3 i
tad t2 i
dac t1 i
jmp fetch
litrl:
lac sp
tad d1
dac sp i
isz sp
lac pc i
dac sp i
isz sp
jmp fetch
goto:
-2
tad sp
dac sp
lac sp i
dac t1
-1
tad t1 i
dac pc
jmp fetch
retrn:
-2
tad sp
dac sp
lac sp i
dac t1
lac t1 i
lmq
lac dp
dac sp
dac t1
lac sp i
sna
jmp stop
dac dp
isz sp
lac sp
dac t1 i
lac sp i
dac pc
lacq
dac sp i
isz sp
jmp fetch
escp:
law 2
tad pc
dac t1
jmp t1 i
setop:
lac addr
tad dp
dac sp
jmp fetch
traop:
-1
tad addr
dac pc
jmp fetch
unaop:
-1
tad sp
dac t3
tad dm1
dac t2
lac t2 i
dac t1
lac t3
dac t2 i
lac addr
tad .+3
dac .+1
jmp .. i
jmp . i
uadr; umin; uind; unot
badr:
lac t1
dac t3 i
jmp fetch
bmin:
-1
tad t1 i
cma
dac t3 i
jmp fetch
bind:
lac t1 i
dac t2 i
jmp fetch
bnot:
lac t1 i
sna cla
lac d1
dac t3 i
jmp fetch
extop:
lac addr
dac sp i
isz sp
isz sp
jmp fetch
aryop:
lac addr
tad dp
dac t1
tad d1
dac t1 i
jmp fetch
a = 040000
b = a+a
c = b+a
f = c+a
n = f+a
s = n+a
t = s+a
u = t+a
x = u+a
f = x+a
d1: 1
dm1: -1
dm2: -2
o17777: 017777
:1: 0
:2: 0
:3: 0
:4: 0
:ddr: 0
pc = 017
sp: stack
dp: stack
ip: stack
stack: 0

194
scans/bl.s Normal file
View File

@@ -0,0 +1,194 @@
" bl
jmp start
.array: .+1
s 2
n 8
n 7
-1
tad sp i
cma
tad lastv
dac lastv
imq
lac sp
tad d1
dac sp i
isz sp
lacq
dac sp i
isz sp
jmp fetch
.read: .+1
s 2
n 8
n 7
lac sp
tad d1
dac sp i
isz sp
jms getc
dac sp i
isz sp
jmp fetch
.write: .+1
s 2
n 8
n 7
lac sp i
dac t1
lrss 9
jms putc
lac t1
jms putc
jmp fetch
.flush: .+1
n 8
n 7
jms flush
jmp fetch
getc: 0
lac iflg
dzm iflg
sza
jmp getc i
lac cibufp
sad eibufp
jmp 1f
lac cibufp i
and o777
dac iflg
lac cibufp i
isz cibufp
lrss 9
jmp getc i
1:
lac .fin
sys read; ibufp: ..; 64
sna spa
jmp 1f
tad ibufp
dac eibufp
lac ibufp
dac cibufp
jmp getc+1
1:
lac 0o4
jmp getc i
putc: 0
and 0777
sna
jmp putc i
imq
lac oflg
sza
jmp 1f
lacq
alss 9
dac cobufp i
dac oflg
jmp putc i
1:
lac cobufp i
omq
dac cobufp i
dac cobufp i
dzm oflg
isz cobufp
lac cobufp
sad eobufp
skp
jmp putc i
lac .fout
sys write; obufp: ..; 64
lac obufp
dac cobufp
jmp putc i
stop:
jms flush
las
sma
sys save
sys exit
flush: 0
lac oflg
sza
isz cobufp
lac cobufp
cma
tad obufp
cma
sna
jmp flush i
dac 1f+1
lac obufp
dac 1f
lac .fout
sys write; 1: :.; ..
lac obufp
dac cobufp
dzm oflg
jmp flush i
initio: 0
lac 017777 i
sad d4
jmp 2f
sad d8
jmp 1f
law 9
tad 017777
dac .+3
law 017
sys creat; ..
spa
jmp stop
dac .fout
1:
law 5
tad 017777
dac .+2
sys open; ..; 0
spa
jmp stop
dac .fin
2:
lac lastv
dac eibufp
dac cibufp
-64
tad lastv
dac lastv
dac ibufp
lac lastv
dac eobufp
-64
tad lastv
dac lastv
dac obufp
dac cobufp
dzm oflg
jmp initio i
.fin: 0
.fout: 1
eibufp: 0
cibufp: 0
iflg: 0
eobufp: 0
cobufp: 0
oflg: 0
lastv: 017770
o777: 0777
d4:o4: 4
d8: 8

1059
scans/cas.s Normal file

File diff suppressed because it is too large Load Diff

771
scans/ed1.s Normal file
View File

@@ -0,0 +1,771 @@
"** 08-rest.pdf page 8
"[handwritten page number top right of scan - 1]
" ed1
lac d1
sys write; 1f; 3
lac o17
sys creat; tname
spa
sys save
dac sfo
sys open; tname; 0
spa
sys save
dac sfi
-1
tad lnodp
dac zermp
tad d1
dac zerop
dac dot
tad d1
dac eofp
dzm i eofp
dzm i zerop
dzm lastre
dzm fbuf
lac d1
dac dskadr
dac wrlfg
dzm diskin
"o------------> [scan markup]
jmp advanc
1:
<ed>; <it>; 012
advanc:
jms rline
lac linep
dac tal
dzm adrflg
jms addres
jmp comand
-1
dac adrflg
lac addr
dac addr1
dac addr2
1:
lac char
sad o54
jmp 2f
sad o73
skp
jmp chkwrp
lac addr
dac dot
2:
jms addres
jmp error
lac addr2
dac addr1
lac addr
dac addr2
jmp 1b
"** 08-rest.pdf page 9
"[handwritten page number top right of scan - 2]
chkwrp:
-1
tad addr1
jms betwen; d1; addr2
jmp error
comand:
lac char
sad o141
jmp ca
sad o143
jmp cc
sad o144
jmp cd
sad o160
jmp cp
sad o161
jmp cq
sad o162
jmp cr
sad o163
jmp cs
sad o167
jmp cw
sad o12
jmp cnl
sad o75
jmp ceq
jmp error
ca:
jms newline
jms setfl
lac addr2
dac dot
ca1:
jms rline
lac line
sad o56012
jmp advanc
jms append
jmp ca1
cc: cd:
jms newline
jms setdd
lac addr1
sad zerop
jmp error
dac dot
tad dm1
dac 9
lac addr2
dac 8
2:
lac i 8
dac i 9
sza
jmp 2b
"??? illegible line cut off - dac 0, lac 0, something else???
"** 08-rest.pdf page 10
"[handwritten page number top right of scan - 3]
dac eofp
lac char
sad o144
jmp advanc
-1
tad dot
dac dot
jmp ca1
cp:
jms newline
cp1:
jms setdd
lac addr1
sad zerop
jmp error
1:
lac addr1
dac dot
lac i addr1
jms gline
dac 2f
lac d1
sys write; line; 2: 0
lac addr1
sad addr1
jmp advanc
tad d1
dac addr1
jmp 1b
cq:
jms newline
lac adrflg
sza
jmp error
sys exit
cr:
jms setfl
lac addr2
dac dot
jms rname
"------------> [scan markup]
sys open; fbuf; 0
spa
jmp error
dac tfi
lac linep
dac tal
dzm num
1:
lac tfi
sys read; tbuf; 64
sza
jmp 2f
lac tfi
sys close
jms number
jmp advanc
2:
"??? illegible line cut off - cma, sma, something else?
"** 08-rest.pdf page 11
"[handwritten page number top right of scan - 4]
tad d1
rcl
dac c1
lac tbufp
dac tal1
2:
jms getsc; tal1
sna
jmp 3f
jms putsc; tal
isz num
sad o12
skp
jmp 3f
lac tal
add o400000
and o17777
cma
tad linep
cma
dac linsiz
jms append
lac linep
dac tal
3:
isz c1
jmp 2b
jmp 1b
cw:
jms setfl
lac i addr1
sna
jmp error
jms rname
lac o17
sys creat; fbuf
spa
jmp error
dac tfi
-128
dac c2
lac tbufp
dac tal1
dzm num
1:
lac i addr1
jms gline
rcl
cma
tad d1
dac c1
lac linep
dac tal
2:
jms getsc; tal
sna
jmp 3f
isz num
jmp putsc; tal1
isz c2 "???
"** 08-rest.pdf page 12
"[handwritten page number top right of scan - 5]
jmp 3f
lac tfi
sys write; tbuf; 64
-128
dac c2
lac tbufp
dac tal1
3:
isz c1
jmp 2b
lac addr1
sad addr2
jmp 1f
isz addr1
jmp 1b
1:
lac tal1
sma cla
jmp 1f
jms putsc; tal1
1:
-1
tad tufp
cma
tad tal1
dac 1f
lac tfi
sys write; tbuf; 1: 0
lac tfi
sys close
jms number
jmp advanc
cn1:
lac adrflg
sna
jmp 1f
lac addr2
dac addr1
jmp cp1
1:
lac dot
tad d1
sad eofp
jmp error
dac dot
jmp cp1
ceq:
jms newline
jms setfl
lac addr2
dac dot
cma
tad zerop
cma
dac num
jms number
jmp advanc
setdd: 0
"** 08-rest.pdf page 13
"[handwritten page number top right of scan - 6]
lac adrflg
sza
jmp i setdd
lac dot
dac addr1
dac addr2
jmp i setdd
setfl: 0
lac adrflg
sza
jmp i setfl
lac zerop
tad d1
dac addr1
-1
tad eofp
dac addr2
jmp i setfl
newline: 0
jms getsc; tal
sad o12
jmp i newline
jmp error
addres: 0
dzm minflg "..) [stray scan mark?]
-1
dac addr
ad1:
jms getsc; tal
ad2:
jms betwen; d47; d56
skp
jmp numb
sad o40 "[o40 circled in scan]
jmp ad1 "[hand drawn check mark follows operand in scan]
sad o11
jmp ad1 "[hand drawn check mark follows operand in scan]
"[check mark underlined in scan]
sad o55
jmp amin "[hand drawn check mark follows operand in scan]
sad o56
jmp adot "[hand drawn check mark follows operand in scan]
sad o53
jmp ad1 "[hand drawn check mark follows operand in scan]
sad o44
jmp adol "[hand drawn check mark follows operand in scan]
sad o57
jmp fsrch "[hand drawn check mark follows operand in scan]
sad o77
jmp bsrch "[hand drawn check mark follows operand in scan]
dac char
lac minflg
sza
jmp error
lac addr
sma
isz addres
jmp i addres
"** 08-rest.pdf page 14
"[handwritten page number top right of scan - 7]
adot:
lac minflg
sza
jmp error
lac addr
sma
jmp error
lac dot
dac addr
jmp ad1
adol:
lac minflg
sza
jmp error
lac addr
sma
jmp error
-1
tad eofp
dac addr
jmp ad1
amin:
-1
dac minflg
jmp ad1
numb:
dac char
sad o60
jmp 1f
lac d10
jmp 2f
1:
lac d8
2:
dac 2f
dzm num
1:
lac num
cll; mul; 2: 0
lacq
tad char
tad dm48
dac num
jms getsc; tal
dac char
jms betwen; d47; d58
skp
jmp 1b
lac minflg
sna
jmp 1f
-1
tad num
cma
dac num
dzm minflg
1:
lac addr
"** 08-rest.pdf page 15
"[handwritten page number top right of scan - 8]
spa
lac zerop
tad num
dac addr
jms betwen; zermp; eofp
jmp error
lac char
jmp ad2
number: 0
lac d100000
dac n1
law tbuf-1
dac 8
n0:
lac num
cll; idiv; n1: 0
dac num
lacq
tad d48
dac i 8
lac n1
cll; idiv; 10
lacq
dac n1
sza
jmp n0
lac o12
dac i 8
law tbuf-1
dac 8
dac 9
-5
dac n1
n2:
lac i 8
sad d48
skp
jmp n3
dzm i 9
isz n1
jmp n2
n3:
lac d1
sys write; tbuf; 7
jmp i number
rname: 0
lac fbufp
dac tal1
-8
dac c1
1:
jms getsc; tal
sad o40
jmp 1b
sad o12
jmp 1f
jms putsc; tal1
isz c1
jmp 1b
"** 08-rest.pdf page 16
"[handwritten page number top right of scan - 9]
jmp i rname
1:
lac tal1
sad fbufp
skp
jmp 1f
lac fbuf
sna
jmp error
jmp i rname
1:
lac o40
jms putsc; tal1
isz c1
jmp 1b
jmp i rname
gline: 0
dac glint1
jms getdsk
lac glint1 " [these 6 lines were surrounded by a box
adn o17777 " that was Xed out with an arrow pointing to it]:
tad dskbfp " --
dac ital "|\/|
lac linep "|/\|<---
dac otal " --
1:
lac ital
sad edskbfp
skp
jmp 2f
lac diskin
tad d1024
jms getdsk
lac dskbfp
dac ital
2:
jms getsc; ital
jms putsc; otal
sad o12
skp
jmp 1b
lac otal
sma
jmp 1f
cla
jms putsc; otal
1:
lac linpm1
cma
tad otal
jmp i gline
rline: 0
lac linep
dac tal
1:
cla
sys read; char; 1
lac char
"** 08-rest.pdf page 17
"[handwritten page number top right of scan - 10]
lrss 9
jms esc
lac char
and o777
jms esc
jmp 1b
esc: 0
sna
jmp i esc
jms putsc; tal
sad o12
jmp 2f
sad o100
jmp 1f
sad o43
skp
jmp i esc
-1
tad tal
dac tal
and o17777
sad linpm1
jmp 1f
jmp i esc
1:
lac linep
dac tal
jmp i esc
2:
lac tal
sma cla
jmp 1f
jms putsc; tal
1:
-1
tad linep
cma
tad tal
dac linsiz
jmp i rline
getsc: 0
lac i getsc
dac sctalp
isz getsc
lac i sctalp
dac sctal
add o400000
dac i sctal
ral
lac i sctal
szl
lrss 9
and o777
jmp i getsc
putsc: 0
and o777
"** 08-rest.pdf page 18
"[handwritten page number top right of scan - 11]
lmq
lac i putsc
dac sctalp
isz putsc
lac i sctalp
dac sctal
add o400000
dac i sctalp
sma cla
jmp 1f
llss 27
dac i sctal
lrss 9
jmp i putsc
1:
lac i sctal
and o777000
omq
dac i sctal
lacq
jmp i putsc
append: 0
-1
tad eofp
dac 8
cma
tad dot
dac apt1
1:
lac i 8
dac i 8
-3
tad 8
dac 8
isz apt1
jmp 1b
isz eofp
dzm i eofp
isz dot
jms addline
jmp i append
addline: 0
lac dskadr
dac i dot
jms getdsk "[line crossed out - scan markup]
-1
tad linsiz
cma
dac apt1
law line-1
dac 8
lac dskadr "[line crossed out - scan markup]
and o1777 "[line crossed out - scan markup]
tad dskbfp "[line crossed out - scan markup]
dac otal "[line crossed out - scan markup]
lac dskadr "[line crossed out - scan markup]
tad linsiz "[line crossed out - scan markup]
dac dskadr "[line crossed out - scan markup]
"** 08-rest.pdf page 19
"[handwritten page number top right of scan - 12]
1:
lac otal " [these 9 lines were surrounded by a box
sad edskbfp " that was Xed out]:
skp " --
jmp 2f "|\/|
lac diskin "|/\|
tad d1024 " --
jms getdsk "
lac dskbfp "
dac otal "
2: "[line crossed out - scan markup]
lac i 8
dac i otal "[line crossed out and a note that looks like *jous prtwrd*]
isz otal
dzm wrflg "[line crossed out - scan markup]
isz apt1
jmp 1b
jmp i addline
getdsk: 0 "[the entire getdsk procedure was surrounded
and o776000 " by a box that was Xed out]:
sad diskin " --
jmp i getdsk "|\/|
dac 2f "|/\|
lac wrflg " --
sza "
jmp 3f "
lac diskin "
dac 1f "
lac sfo "
sys seek; 1: 0; 0 "
lac sfo "
sys write; dskbuf; 1024 "
lac d1 "
dac wrflg "
3: "
lac 2f "
dac diskin "
lac sfi "
sys seek; 2: 0; 0 "
spa "
jmp i getdsk "
lac sfi "
sys read; dskbuf; 1024 "
jmp i getdsk "
betwen: 0
dac bett1
lac i betwen
dac bett2
isz betwen
lac i bett2
cma
tad bett1
spa
jmp 1f
lac i betwen
dac bett2
isz betwen
-1
tad i bett2
"** 08-rest.pdf page 20
"[handwritten page number top right of scan - 13]
cma
tad bett1
spa
1:
isz betwen
lac bett1
jmp i betwen
error:
lac d1
sys write; 1f; 1
jmp advanc
1:
077012

519
scans/ed2.s Normal file
View File

@@ -0,0 +1,519 @@
"** 08-rest.pdf page 21
"[handwritten page number top right of scan - 14]
" ed2
cs:
jsm getsc; tal
sad o40
jmp cs
sad o12
jmp error
dac delim
jms compile
lac tbufp
dac tal1
1:
jms getsc; tal
sad delim
jmp 1f
sad o12
jmp error
jms putsc; tal1
jmp 1b
1:
lac o12
jms putsc; tal1
jms newline
jms setdd
lac addr1
sad zerop
jmp error
1:
dac addr1
lac i addr1
jms execute
jmp 2f
lac addr1
dac dot
law line-1
dac 8
law nlist-1
dac 9
-64
dac c1
3:
lac i 8
dac i 9
isz c1
jmp 3b
-1
tad fchrno
dac linsiz
rcr
szl
xor o400000
tad linep
dac tal1 "???
lac tbufp
dac tal
3:
jms getsc; tal
sad o12
jmp 3f
jms putsc; tal1
isz linsiz "???
"** 08-rest.pdf page 22
"[handwritten page number top right of scan - 15]
jmp 3b
3:
-1
tad lcrhno
rcr
szl
xor o400000
tad nlistp
dac tal
3:
jms getsc; tal
jms putsc; tal1
isz linsiz
sad o12
skp
jmp 3b
jms addline
2:
lac addr1
sad addr2
jmp advanc
tad d1
jmp 1b
fsrch:
dac delim
jms compile
jms srcsav
lac dot
floop:
tad d1
dac addr
lac i addr
sza
jmp 1f
lac zerop
dac addr
jmp 2f
1:
jms execute
jmp 2f
jms srcres
jmp ad1
2:
lac addr
sad dot
jmp error
jmp floop
bsrch:
dac delim
jms compile
jms srcsav
lac dot
dad zerop
lac eofp
bloop:
tad dm1
dac addr
lac i addr
"** 08-rest.pdf page 23
"[handwritten page number top right of scan - 16]
sza
jmp 1f
lac eofp
dac addr
jmp 2f
1:
jms execute
jmp 2f
jms srcres
jmp ad1
2:
lac addr
sad dot
jmp error
jmp bloop
srcsav: 0
lac minflg
sza
jmp error
lac addr
sma
jmp error
law line-1
dac 8
law tbuf-1
dac 9
-64
dac c1
1:
lac i 8
dac i 9
isz c1
jmp 1b
jmp i srcsav
srcres: 0
law tbuf-1
dac 8
law line-1
dac 9
-64
dac c1
1:
lac i 8
dac i 9
isz c1
jmp 1b
jmp i srcres
compile: 0
law compbuf-1
dac 8
dzm prev
dzm compflg
cadvanc:
jms getsc; tal
sad delim
jmp cdone
dac compflg "???
"** 08-rest.pdf page 24
"[handwritten page number top right of scan - 17]
dzm lastre
sad o12
jmp error
"sad o133
"jmp chrcls
sad o136 "???
jmp beglin
sad o44
jmp endlin
"sad o52
"jmp clsure
dac 1f
jmp comp
1; jms matchar; 1: 0; 0
jmp cadvanc
cdone:
lac compflg
sna
jmp 1f
dac lastre
jms comp
1; jms found; 0
jmp i compile
1: "???
lac lastre
sna
jmp error
jmp i compile
chrcls:
jmp error
beglin: "???
jms comp
1; jms matbol; 0
dzm prev
jmp cadvanc
endlin: "???
jms comp
1; jms mateol; 0
dzm prev
jmp cadvanc
clsure:
lac prev
sna
jmp error
tad d1
dac 1f
jms comp
1; jms matclo; 1: 0; 0
dzm prev
jmp cadvanc
comp: 0 "???
-1
tad comp
dac 9
lac 8 "???
"** 08-rest.pdf page 25
"[handwritten page number top right of scan - 18]
dac prev
1: "???
lac i 9
sna
jmp i 9
dac i 8
jmp 1b
execute: 0
jms gline
lac linep
dac tal1
dzm charno
dzm fchrno
dzm lchrno
lac jmpclist
dac trvect
lac jmpnlist
dac trvect+1
lac jmpxchg
dac i trvect+1
jmp 1f
exchg: "???
lacq
sad o12
jmp i execute
lac jmpxchg
dac i 8
1: "???
lac trvect
lmq
lac trvect+1
dac trvect
lacq
dac trvect+1
tad dm1
dac 8
jms getsc; tal1
lmq
isz charno
jms compbuf
charno:
0
trvect:
0;0
matchar: 0 "???
-2
tad matchar
dac exret
lac i exret
dac exret
lacq
sad i matchar
skp
jmp 1f
lac matchar
adn o17777
tad jms1
dac i 8 "??? [unreadable page cutoff]
"** 08-rest.pdf page 26
"[handwritten page number top right of scan - 19]
lac i exret
dac i 8
1: "???
isz exret
jmp i exret
found: 0
-2
tad found
dac exret
lac i exret
dac exret
lac fchrno
sza
jmp 1f
isz execute
jmp 2f
1: "???
sad i exret
jmp 1f
cma
tad i exret
spa
jmp 2f
jmp 3f
1: "???
lac charno
cma
tad charno
spa
jmp 3f
2: "???
lac i exret
dac fchrno
lac charno
dac lchrno
3: "???
isz exret
jmp i exret
matbol: 0 "???
lac charno
sad d1
jmp 1f
lac matbol
jmp 2f
1: "???
lac matbol
jmp 3f
mateol: 0 "???
lacq
sad o12
jmp 1f
lac mateol
2: "???
tad dm2
dac exret
lac i exret
dac 9
"??? [line is cut off in scan, maybe lac i 8 or jmp i 9]
"** 08-rest.pdf page 27
"[handwritten page number top right of scan - 20]
1: "???
lac mateol
3: "???
tad dm3
dac 9
lac i 9
isz 9
dac i 9
jmp i 9
matclo: 0 "???
-2
tad matclo
dac exret
lac i exret
dac cloret
lac i cloret
dac 1f
dac 2f
lac i matclo
dac exret
jms i exret; 1: 0
isz matclo
jms i matclo; 2: 0
isz cloret
jmp i cloret
"??? the remainder of this scan had an unreadable first character
"??? I did the best I could to recreate the characters appropriately
o1: 1
o133: 0133
dm3: -3
o136: 0136
dm2: -2
o52: 052
o57: 057
o77: 077
o40: 040
o12: 012
d47: 47
d58: 58
dm48: -48
d10: 10
d8: 8
d48: o60: 060
d100000: 100000
o44: 044
o53: 053
o56: 056
o55: 055
o11: 011
o400000: 0400000
o17777: 017777
o144: 0144
dm1: -1
o56012: 056012
o777: 0777
o100: 0100
o43: 043
o777000: 0777000
o75: 075
o167: 0167
o161: 0161
"** 08-rest.pdf page 28
"[handwritten page number top right of scan - 21]
o160: 0160
o143: 0143
o141: 0141
o1777: 01777
d1024: 1024
o776000: 0776000
o162: 0162
o163: 0163
o73: 073
o54: 054
o17: 017
tname:
0145056;0164155;0160040;040040
tbufp: tbuf
linep: line
nlistp: nlist
fbufp: fbuf
dskbfp: dskbuf "[line crossed out - scan markup]
edskbfp: dskbuf+1024 "[line crossed out - scan markup]
lnodp: lnodes
linpm1: line-1
jmpclist: jmp clist
jmpnlist: jmp nlist
jmpxchg: jmp xchg
jms1: jms 1
tal: .=.+1
exret: .=.+1
cloret: .=.+1
delim: .=.+1
prev: .=.+1
compflg: .=.+1
tal1: .=.+1
c1: .=.+1
ital: .=.+1
otal: .=.+1
diskin: .=.+1
glint: .=.+1
c2: .=.+1
num: .=.+1
zermp: .=.+1
minflg: .=.+1
adrflg: .=.+1
dot: .=.+1
addr: .=.+1
addr1: .=.+1
addr2: .=.+1
eofp: .=.+1
zerop: .=.+1
dskadr: .=.+1
linsiz: .=.+1
tfi: .=.+1
fchrno: .=.+1
lchrno: .=.+1
lastre: .=.+1
bett1: .=.+1
bett2: .=.+1
wrflg: .=.+1
apt1: .=.+1
"[page cuts off one label]
"** 08-rest.pdf page 29
"[handwritten page number top right of scan - 22]
sfo: .=.+1
sctal: .=.+1
sctalp: .=.+1
char: .=.+1
fbuf: .=.+4 "not sure if this is fbuf, but
tbuf: .=.+64 "there is a write; tbuf; 64 call
line: .=.+64
nlist: .=.+50
"??? ?list: .=.+50, unable to determine label
compbuf: .=.+100
dskbuf: .=.+1 "[line crossed out - scan markup]
lnodes: .=.+1000

26
scans/ind.b Normal file
View File

@@ -0,0 +1,26 @@
main $(
extrn read, write;
auto i, c, state, line 100;
loop:
state = i = 0;
loop1:
c = read();
if(c==4) return;
if(c==';' & state==0) state = 2;
if((c<'0' ^ c>'9'&c<'a' ^ c>'z') & state==0) state = 1;
line[i] = c;
i = i+1;
if(c!=012) goto loop1;
if(state==2 ^ i==1) goto noi;
write(' ');
write(' ');
noi:
i = 0;
loop3:
c = line[i];
write(c);
i = i+1;
if(c!=012) goto loop3;
goto loop;
$)

20
scans/lease.b Normal file
View File

@@ -0,0 +1,20 @@
main $(
auto ch;
extrn read, write;
goto loop;
while (ch != 04)
$( if (ch > 0100 & ch < 0133)
ch = ch + 040;
if (ch==015) goto loop;
if (ch==014) goto loop;
if (ch==011)
$( ch = 040040;
write(040040);
write(040040);
$)
write(ch);
loop:
ch = read()&0177;
$)
$)

52
scans/maksys.s Normal file
View File

@@ -0,0 +1,52 @@
"** 01-s1.pdf page 64 -- handwritten maksys
" copy a.out to disk track 18x
" where x is the argument
lac 017777 i; sad d8; skp; jmp error
lac 017777; tad d5; dac track
lac i track; lrss 9; tad om60
spa; jmp error; dac track
tad dm10; sma; jmp error
sysopen; a.out; 0
spa; jmp error
sys read; bufp; buf; 3072
sad .-1
jmp error
dscs
-3072; dslw
lac bufp; dslm
lac track; alss 8; xor o300000; dsld
lac o30000; dsls
dssf; jmp .-1
dsrs; spa; jmp error
-1024; dslw
lac d3072; dslm
lac track; alss 8; xor o300110; dsld
lac o3000; dsls
dssf; jmp .-1
dsrs; spa; jmp error
sys exit
error:
lac d1; sys write; 1f; 2
sys exit
1: 077077;012
dm10: -10
dm5: 5
om60: -060
o300000: 0300000
o300100: 0300110
d8: 8
d3072: 3072
o3000: 03000
d1: 1
a.out:
<a.>;<ou>;<t 040;040040
track: .=.+1
buf:

View File

@@ -102,31 +102,94 @@ swap: 0
dac u.ulistp i
ion
jmp dskswap; 07000
lac u.dspbuf
sna
jmp 2f
law dspbuf
jms movdsp
2:
iof
lac o600000
tad 9f+t i
dac 9f+t i
ion
jms dskswap; 06000
lac u.swapret
dac swap
lac o20
dac maxquant
lac u.dspbuf
sza
"** 01-s1.pdf page 4
jms movdsp
3:
dzm uquant
iof
jmp swap i
t = t+1
" For now, this stuff is defined so that
" the assembler doesn't complain about it
swp:
jmp .
.save; .getuid; .open; .read; .write; .creat; .seek; .tell
.close; .link; .unlink; .setuid; .rename; .exit; .time; .intrp
.chdir; .chmod; .chown; badcal; .sysloc; badcal; .capt; .rele
.status; badcal; .smes; .rmes; .fork
swn:
.-swp-1 i
.intrp:
lac u.ac
dac u.intflg
jmp okexit
.sysloc:
lac u.ac
and o17777
jms betwen; d1; locn
jms error
tad locsw
dac .+1
lac ..
dac u.ac
jmp sysexit
locsw:
lac .
iget; inode; userdata; sysdata; copy; copyz; betwen; dskrd
dskwr; dskbuf; dpdata; namei; pbsflgs; alloc; free; dspdata
crdata
locn:
.-locsw-1
pibreak: 23
u.ac: 100
u.mq: 3
u.rq: 3
copy: 7
.savblk: 0
.insys: 0
uquant: 0
betwen: 0
maxquant: 0
laci: 0
swp: 0
badcal: 0
coldentry: 0
halt: 0
dskio: 0
sysdata: 0
dskbuf: 0
o7000: 07000
o20001: 020001
chkint: 0
.save: 0
lookfor: 0
lac .insys
sza
jmp chkint i
lac .int1
sna
jmp 1f
sad u.ofiles+2
jmp 2f
1:
lac .int2
sna
jmp chkint i
sad chkint i
sad u.ofiles+2
skp
jmp chkint i
dzm .int2
jmp 1f
2:
dzm .int1
1:
"** 01-s1.pdf page 5
lac u.intflg
sza
jmp chkint i
-1
dac .insys
ion
isz chkint
jmp chkint i

334
scans/s2.s Normal file
View File

@@ -0,0 +1,334 @@
"** 01-s1.pdf page 7
" s2
.status:
jms arg
dac .+5
jms arg
dac .+6
lac u.cdir
jms namei; ..
jms error
jms namei; ..
jms error
jms iget
lac u.ac
and o17777
jms betwen; o10000; o17762
jms error
dac .+3
jms copy; inode; ..; 12
dac 9 i
jmp okexit
.capt:
lac u.ac
dac u.dspbuf
jms movdsp
jmp sysexit
.rele:
dzm u.dspbuf
law dspbuf
jms movdsp
jmp sysexit
.chmod:
jms isown
lac u.ac
and o17
lmq
lac i.flags
and o777760
omq
dac i.flags
jms iput
jmp okexit
.chown:
jms isown
lac u.ac
dac i.uid
jms iput
jmp okexit
.getuid:
lac u.uid
dac u.ac
jmp sysexit
.seek:
jms seektell
tad u.base
"** 01-s1.pdf page 8
spa
jms error
lmq
lac f.flags
and d1
sna
jms 1f
lacq
jms betwen; d0; i.size
jms dacisize
jmp 2f
1:
lacq
jms betwen; d0; i.size
lac i.size
2:
dac f.badd
dac u.ac
jms fput
jmp sysexit
.tell:
jms seektell
cma
tad d1
tad u.base
dac u.ac
jmp sysexit
.link:
jms arg
dac 0f
jms arg
dac 1f
jms arg
dac 2f
lac d4
jms namei; 0:0
jms error
jms namei; 1:0
jms error
dac u.base
jms copy; 2:0; name; 4
lac u.cdir
jms namei; name
skp
jms error
lac d1
dac mode
jms access
jms dslot
lac u.base
jms iget
lac ii
dac d.i "** ??
jms copy; name; d.name; 4
lac i.uniq
dac d.uniq
-1
tad i.nlks
dac i.nlks
"** 01-s1.pdf page 9
jms iput
jms dput
jms okexit
.unlink:
jms argname
dac u.base
lac d1
dac mode
jms access
dac d.i
jms dput
lac u.base
jms u.base
jms iget
isz i.nlks
jmp 1f
jms itrunc
dzm i.flags
1:
jms iput
jmp sysexit
.setuid:
lac u.uid
sma
jms error
lac u.ac
dac u.uid
jmp sysexit
.rename:
jms arg
dac 0f
jms arg
dac 1f
lac u.cdir
jms namei; 0:0
jms error
lac d1
dac mode
jms access
jms copy; 1:0; d.name; 4
jmp okexit
.time:
lac s.tim
dac u.ac
lac s.tim+1
dac u.mq
jmp sysexit
.chdir:
jms argname
jms iget
lac i.flags
and o20
sna
jms error
lac ii
dac u.cdir
"** 01-s1.pdf page 10
jmp okexit
.open:
jms arg
dac 0f
jms arg
sza
lac d1
sna
lac d2
dac mode
lac u.cdir
jms namei; 0:0
jms error
jms iget
jms access
lac i.flags
and o20
sna
jmp open1
lac mode
and d1
sna
jmp open1
lac u.uid
sma
jms error
jmp open1
.creat:
lac d1
dac mode
jms arg
dac .+2
jms copy; ..; name; 4
lac u.cdir
jms namei; name
jmp 1f
jms iget
jms access
lac i.flags
and o20
sna
jmp .+4
lac u.uid
sma
jms error
jms itrunc
cla
jms dacisize
jmp open1
1:
jms access
lac u.ac
and o17
jms icreat
open1:
jms fassign
jms error
jmp sysexit
"** 01-s1.pdf page 11
.close:
jms finac
dzm f.flags
jms fput
jmp sysexit
.read:
jms arg
and o17777
dac u.base
jms arg
dac u.count
lac u.base
jms betwen; o10000; o17777
jms error
tad u.count
jms betwen; u.base; o17777
jms error
dac u.limit
1:
jms finac
lac f.flags
and d1
sza
jms error
lac i.flags
and o40
sna
jmp 1f
iof
lac ii
tad swr
dac .+1
jmp .. i
1:
lac u.base
dac 1f+1
lac u.count
dac 1f+2
lac f.badd
1:
jms iread; ..; ..
jmp exitrw
.write:
jms arg
and o17777
dac u.base
jms arg
dac u.count
tad u.base
jms betwen; u.base; o17777
jms error
dac u.limit
jms finac
lac f.flags
and d1
sna
jms error
lac i.flags
and o40
"** 01-s1.pdf page 12
sna
jmp 1f
iof
lac ii
tad sww
dac .+1
jmp .. i
1:
lac u.base
dac 1f+1
lac u.count
dac 1f+2
lac f.badd
1:
jms iwrite; ..; ..
exitrw:
dac u.ac
tad f.badd
dac f.badd
jms iput
jms fput
jmp sysexit

355
scans/s3.s Normal file
View File

@@ -0,0 +1,355 @@
"** 01-s1.pdf page 14
" s3
searchu: 0
lac searchu i
dac 9f+t+1
-mnproc
dac 9f+t
law ulist-1
dac 8
1:
lac 8 i
dac lu
lac 8 i
dac lu+1
lac 8 i
dac lu+2
lac 8 i
dac lu+3
jms 9f+t+1 i
isz 9f+t
jmp 1b
isz searchu
jmp searchu i
lookfor: 0
jms searchu; 1f
isz lookfor
isz lookfor
jmp lookfor i
1: 0
lac lu
rtl; rtl; and o7
sad lookfor i
skp
jmp 1b i
-3
tad 8
and o17777
isz lookfor
jmp lookfor i
.fork:
jms lookfor; 0 " not-user
skp
jms error
dac 9f+t
isz uniqpid
lac uniqpid
dac u.ac
law sysexit
dac u.swapret
lac o200000
tad u.ulistp i
dac u.ulistp i
jms dskswap; 07000
lac 9f+t
dac u.ulistp
lac o100000
xor u.ulistp i
dac u.ulistp i
lac u.pid
"** 01-s1.pdf page 15
dac u.ac
lac uniqpid
dac u.pid
isz 9f+t
dac 9f+t i
isz u.rq+8
dzm u.intflg
jmp sysexit
t= t+1
badcal:
clon
-1
dac 7
.save:
lac d1
jms iget
cla
jms iwrite; 4096; 4096
jms iwrite; userdata; 64
jms iput
.exit:
lac u.dspbuf
sna
jmp .+3
law dspbuf
jms movdsp
jms awake
lac u.ulistp i
and o77777
dac u.ulistp i
isz u.ulistp
dzm u.ulistp i
jms swap
.rmes:
jms awake
lac o100000
tad u.ulistp i
dac u.ulistp i
law 2
tad u.ulistp
dac 9f+t
-1
dac 9f+t i
jms swap
law 2
tad u.ulistp
dac 9f+t
lac 9f+t i
cma
dac u.ac
dzm 9f+t i
isz 9f+t i
lac 9f+t i
dac u.mq
dzm 9f+t i
jmp sysexit
t = t+1
"** 01-s1.pdf page 16
.smes:
lac u.ac
sna spa
jms error
jms searchu; 1f
law 2
tad u.ulistp
dac 9f+t
dzm 9f+t i
jms error
1: 0
lac lu+1
sad u.ac
skp
jmp 1b i
lac lu+2
sad dm1
jmp 1f
lac o100000
tad u.ulistp i
dac u.ulistp i
law 2
tad u.ulistp
dac 9f+t
lac u.ac
dac 9f+t i
jms swap
law 2
tad u.ulistp
dac 9f+t
dzm 9f+t i
jmp .smes
1:
-3
tad 8
dac 9f+t
lac o700000
tad 9f+t i
dac 9f+t i
isz 9f+t
isz 9f+t
lac u.pid
cma
dac 9f+t i
isz 9f+t
lac u.mq
dac 9f+t i
jmp okexit
t = t+1
awake: 0
jms searchu; 1f
jmp awake i
1: 0
lac u.pid
sad lu+2
skp
jmp 1b i
-3
tad 8
dac 9f+t
"** 01-s1.pdf page 17
lac o700000
tad 9f+t i
dac 9f+t i
jmp 1b i
t = t+1
swr:
sww:
jmp .-4 i
.halt; rttyi; rkbdi; rppti; .halt
.halt; wttyo; wdspo; wppto
.halt: jms halt
rttyi:
jms chkint1
lac d1
jms getchar
jmp 1f
and o177
jms betwen o101; o132
skp
tad o40
alss 9
jmp passone
1:
jms sleep; sfiles+0
jms swap
jmp rttyi
wttyo:
jms chkint1
jms forall
sna
jmp failr
lmq
lac sfiles+1
spa
jmp 1f
xor 0400000
dac sfiles+1
lacq
tls
sad o12
jms putcr
jmp failr
1:
lacq
dac char
lac d2 "** written: d6 ttyout
jms putchar
skp
jmp failr
jms sleep; sfiles+1
jms swap
jmp wttyo
rkbdi:
jms chkint1
lac d2
jms getchar
"** 01-s1.pdf page 18
jmp 3f
lmq
and o155
sad o55
jmp 1f
lacq
and o137
sad o134
lacq
xor o40
lmq
jmp 2f
1:
lacq
xor o20
lmq
2:
lacq
dac u.limit
1:
jms chkint1
lac u.limit
jms dspput
jmp 1f
jms sleep; sfiles+6
jms swap
jmp 1b
1:
lac u.limit
alss 9
jmp passone
3:
jms sleep; sfiles+2
jms swap
jmp rkbdi
wdspo:
jms chkint1
jms forall
jms dspput
jmp failr
jms sleep; sfiles+6
jms swap
jmp wdspo
rppti:
lac d4
jms getchar
jmp .+3
alss 9
jmp passone
lac sfiles+3
sma
rsa
1:
jms sleep; sfiles+3
jms swap
jmp rppti
"** 01-s1.pdf page 19
wppto:
jms forall
sna
jmp failr
lmq
lac sfiles+4
spa
jmp 1f
xor o400000
dac sfiles+4
lacq
psa
jmp failr
1:
lacq
dac char
lac d5
jms putchar
skp
jmp failr
jms sleep; sfiles+4
jms swap
jmp wppto
passone:
sad o4000
jmp okexit
dac u.base i
lac d1
dac u.ac
jmp sysexit
error: 0
-1
dac u.ac
jmp sysexit
chkint1: 0
dzm .insys
jmp chkint
skp
jmp .save
-1
dac .insys
jmp chkint1 i

343
scans/s4.s Normal file
View File

@@ -0,0 +1,343 @@
"** 01-s1.pdf page 21
" s4
alloc: 0
-1
tad s.nfblks
spa
jmp 1f
dac s.nfblks
tad fblksp
jms laci
dac 9f+t
jms copyz; dskbuf; 64
lac 9f+t
jms dskwr
dzm .savblk
lac 9f+t
jmp alloc i
1:
lac s.nxfblk
sna
jms halt " OUT OF DISK
dac s.fblks
jms dskrd
lac dskbuf
dac s.nxfblk
jms copy; dskbuf+1; s.fblks+1; 9
lac d10
dac s.nfblks
jmp alloc-1
free: 0
lmq
lac s.nfblks
sad d10
jmp 1f
tad fblksp
dac 9f+t
lacq
dac 9f+t i
dzm .savblk
isz s.nfblks
jmp free i
1:
lac s.nxfblk
dac dskbuf
jms copy; s.fblks+1; dskbuf+1; 9
lacq
dac s.nxfblk
jms dskwr
dzm .savblk
lac d1
dac s.nfblks
jmp free i
t = t+1
laci: 0
and o17777
tad o200000
dac .+1
lac ..
jmp laci i
"** 01-s1.pdf page 22
betwen: 0
lmq cmq
lac betwen i
dac 9f+t
lacq
tad 9f+t i
sma
jmp 1f
lac betwen i
dac 9f+t
isz betwen
lacq
tad 9f+t i
cma
spa sna
1:
isz betwen
lacq
cma
jmp betwen i
copy: 0
-1
tad copy i
dac 8
isz copy
-1
tad copy i
dac 9
isz copy
-1
tad copy i
cma
dac 9f+t
isz copy
1:
lac 8 i
dac 9 i
isz 9f+t
jmp 1b
jmp copy i
copyz: 0
-1
tad copyz i
dac 8
isz copyz
-1
tad copyz i
cma
dac 9f+t
isz copyz
1:
dzm 8 i
isz 9f+t
jmp 1b
jmp copyz i
t = t+1
putchar: 0
"** 01-s1.pdf page 23
dac 9f+t
cla
jms takeq
jmp putchar i
tad o40001
dac .+4
lac 9f+t
jms putq
lac char
lac q2+1 ..
isz putchar
jmp putchar i
t = t+1
getchar: 0
jms takeq
jmp i getchar
tad o200001
dac .+3
cla
jms putq
lac q2+1 ..
isz getchar
jmp i getchar
takeq: 0
rcl
tad lacq1
dac .+7
tad o640000
dac .+17
tad d1
dac .+14
tad o500000
dac .+5
lac q1 ..
sna
jmp takeq i
dac lnkaddr
sad q1+1 ..
jmp .+5
tad o200000
dac .+1
lac q2 ..
jmp .+3
cla
dac q1+1 ..
dac q1 ..
isz takeq
lac lnkaddr
jmp i takeq
putq: 0
rcl
tad dacq1
dac .+14
tad d1
dac .+13
tad o140000
dac .+1
lac q1-1 ..
"** 01-s1.pdf page 24
sna
jmp .+6
tad o40000
dac .+2
lac lnkaddr
dac q2 ..
jmp .+3
lac lnkaddr
dac q1 ..
dac q1+1 ..
jmp putq i
srcdbs: 0
lmq "** written (printed chars obscured)
-ndskbs
dac 9f+t
law dskbs "* -1 dac 8 written
dac 9f+t+1
1:
lac 9f+t+2 "** crossed out
sad 9f+t+1 "** isz 8 written
jmp srcdbs i
law 65 "** crossed out
tad 9f+t+1 "** crossed out isz 8 written
isz 9f+t+1
isz 9f+t
jmp 1b
isz srcdbs
jmp srcdbs i
collapse: 0
cla
jms srcdbs
jmp 1f
law dskbs
dac 9f+t+1 "** 9f+t+1 crossed out: 8 written in
1:
lac 9f+t+1 "** 9f+t+1 crossed out: 8 written in
dac 0f+1
tad d2 "** crossed out: original obscured
dac 0f
cma
tad d1
tad edskbsp
and o17777
sna
jmp 0f+3
dac 0f+2
jms copy; 0:..; ..; ..
-65
tad edskbsp
dac 9f+t
tad d1
dac 0f
lac dskaddr
dac 9f+t i
jms copy; dskbuf; 0:..; 64
jmp collapse i
dskrd: 0
jms betwen; d2; d7999
"** 01-s1.pdf page 25
jms halt
sad dskaddr
jmp dskrd i
dac dskaddr
jms srcdbs
jmp 1f
lac dskaddr
jms dskio; 06000
jmp 1f
1:
dzm 9f+t+1 i
law 1
tad 9f+t+1
dac .+2
jms copy; ..; dskbuf; 64
2:
jms collapse
jmp dskrd i
dskwr: 0
jms betwen; d2; d7999
jms halt
jms dskio; 07000
lac dskaddr
jms srcdbs
dzm 9f+t+1 i
jms collapse
jmp dskwr i
t = t+3
dskio: 0
dac dskaddr
cll; idiv; 80
dac 9f+t
lacq
idiv; 10
dac 9f+t+1
lls 22
xor 9f+t+1
als 8
dac 9f+t+1
lac 9f+t
idiv; 10
dac 9f+t
lls 22
xor 9f+t
jms dsktrans; -64; dskbuf; 9f+t; dskio
isz dskio
jmp dskio i
t = t+1
dsktrans: 0
-10
dac 9f+t
1:
-1
tad dsktrans
dac 12
"** 01-s1.pdf page 26
dscs
lac 12 i
dslw
lac 12 i
dslm
lac 12 i
jms laci
dsld
dzm .dskb
lac 12 i
jms laci
jms laci
dsls
lac .dskb
sna
jmp .-2
lac .dske
sma
jmp 12 i
isz 9f+t
jmp 1b
jms halt " 10 disk errors
t = t+1
halt: 0
isz 9f+t
jmp .-1
iof
hlt
jms copy; law; 4096; 4096
hlt; jmp .-1
t = t+1

277
scans/s5.s Normal file
View File

@@ -0,0 +1,277 @@
"** 01-s1.pdf page 28
" s5
dskswap: 0
cll; als 3
dac 9f+t
jms dsktrans; -64; userdata; 9f+t; dskswap
lac 9f+t
tad o20
dac 9f+t
jms dsktrans; -4096; 4096; 9f+t; dskswap
isz dskswap
jmp dskswap i
t = t+1
access: 0
lac i.flags
idunno "** ???
lac u.uid
spa
jmp access i
sad i.uid
lrs 2
lacq
and mode
sza
jmp access i
jms error
fassign: 0
-1
dac 9f+t
1:
lac 9f+t
tad d10
jms fget
jms halt " will not happen
lac f.flags
sma
jmp 1f
isz 9f+t
jmp 1b
jmp fassign i
1:
lac mode
xor o400000
dac f.flags
lac ii
dac f.i
lac 9f+t
tad d10
dac u.ac
dzm f.badd
jms fput
isz fassign
jmp fassign i
t = t+1
fget: 0
jms betwen; d0; d9
jmp fget i
cll; mul; 3
lacq
"** 01-s1.pdf page 29
tad ofilesp
dac 9f+t
dac .+2
jms copy; ..; fnode; 3
isz fget
jmp fget i
fput: 0
lac 9f+t
dac .+3
jms copy; ; fnode; ..; 3
jmp fput i
t = t+1
forall: 0
lac u.base
sad u.limit
jmp 1f
lac u.base
ral
lac u.base i
snl
lrs 9
and o777
jmp forall i
failr:
lac u.base
add o400000
dac u.base
jmp forall+1
1:
lac u.count
dac u.ac
jmp sysexit
sleep: 0
law ulist-1
dac 8
lac o200000
lmq "** ???
1:
lac u.ulistp i
sad 8 i
jmp 1f
isz 8
isz 8
isz 8
cla; lrs 1
jmp 1b
1:
tad o100000
dac u.ulistp i
lac sleep i
dac 9f+t
lac 9f+t i
isz sleep
jmp sleep i
t = t+1
"** 01-s1.pdf page 30
dslot: 0
dzm di
skp
1:
isz di
lac di
jms dget
lac d.i
sza
jmp 1b
jmp dslot i
icreat: 0
dac 9f+t
jms dslot
lac o20
dac ii
1:
isz ii
lac ii
jms iget
lac i.flags
spa
jmp 1b
lac ii
dac d.i
jms copy; name; d.name; 4
isz s.uniq
lac s.uniq
dac d.uniq
dac i.uniq
lac 9f+t
xor o400000
dac i.flags
lac u.uid
dac u.uid
-1
dac i.nlks
dzm i.size
jms copyz; i.dskps; 7
jms iput
jms dput
jmp icreat i
t = t+1
dspput: 0
and o177
sna
jmp i dspput
sad o14
jmp 1f
lmq
sad o12
jmp dspnl
lac dsploc i
sad o400000
jmp dspleft
omq
dac dsploc i
isz dsploc
jmp i dspput
"** 01-s1.pdf page 31
1:
jms dspinit
jmp dspput i
dspleft:
lac dsploc
sad edspbuf
jmp 1f
dac 8
lac o400000
dac 8 i
cla; llss 18+7
dac dsploc i
jmp dspput i
dspnl: 0
lac dsplno
sad d33
jmp 1f
isz dsplno
jmp dspnl i
1:
lac o2000
wbl
isz dspput
jmp dspput i
dspinit: 0
lac dspbuf+3
dac dsploc
lac o300000
dac dspbuf+3
dzm dsplno
jmp dspinit i
movdsp: 0
iof
caf
dac dspbufp
-1
dac .dspb
ion
jmp movdsp i
arg: 0
lac u.rq+8 i
isz u.rq+8
jmp arg i
argname: 0
jms arg
dac .+2
jms copy; ..; name; 4
lac u.cdir
jms namei; name
jms error
jmp argname i
seektell: 0
jms arg
dac u.base
"** 01-s1.pdf page 32
jms arg
dac u.limit
jms finac
lac u.limit
sna
jmp seektell i
sad d1
jmp .+3
lac i.size
jmp seektell i
lac f.badd
jmp seektell i
isown: 0
jms argname
jms iget
lac u.uid
sma
sad i.uid
skp
jms error
jmp isown i

341
scans/s6.s Normal file
View File

@@ -0,0 +1,341 @@
"** 01-s1.pdf page 34
" S6
itrunc: 0
-7
dac 9f+t
lac idskpp
dac 9f+t+1
1:
lac 9f+t+1 i
sna
jmp 4f
lac i.flags
and o200000
sna
jmp 3f
-64
dac 9f+t+2
lac dskbufp
dac 9f+t+3
2:
lac 9f+t+1 i
jms dskrd
lac 9f+t+3 i
sza
jms free
isz 9f+t+3
isz 9f+t+3
jmp 2b
3:
lac 9f+t+1 i
jms free
dzm 9f+t+1 i
4:
isz 9f+t+1
isz 9f+t
jmp 1b
lac i.flags
and o577777
dac i.flags
jmp itrunc i
t = t+4
namei: 0
jms iget
-1
tad namei i
dac 9f+t+1
isz namei
lac i.flags
and o20
sna
jmp namei i
-8
tad i.size
cma
lrss 3
dac 9f+t
sna
jmp namei i
dzm di
1:
lac di
"** 01-s1.pdf page 35
jms dget
lac d.i
sna
jmp 2f
lac 9f+t+1
dac 8
lac d.name
sad 8 i
skp
jmp 2f
lac d.name+1
sad 8 i
skp
jmp 2f
lac d.name+2
sad 8 i
skp
jmp 2f
lac d.i
isz namei
jmp namei 1
2:
isz di
isz 9f+t
jmp 1b
jmp namei i
t = t+2
iget: 0
dac ii
cll; idiv; 5
dac 9f+t
tad d2
dac 9f+i+1
jms dskrd
lac 9f+t
cll; mul; 12
lacq
tad dskbufp
dac 9f+t
dac .+2
jms copy; ..; inode; 12
jmp iget i
iput: 0
lac 9f+t+1
jms dskrd
law inode-1
dac 8
-1
tad 9f+t
dac 9
-12
dac 9f+t+2
1:
lac 8 i
"** 01-s1.pdf page 36
sad 9 i
skp
jmp 2f
isz 9f+t+2
jmp 1b
jmp iput i
2:
-1
tad 8
dac 8
-1
tad 9
dac 9
1:
lac 8 i
dac 9 i
isz 9f+t+2
jmp 1b
lac 9f+t+1
jms dskwr
jmp iput i
t = t+3
dget: 0
dac di
alss 3
dac 9f+t
jms pget
dac 9f+t+1
jms dskrd
lac 9f+t
and o77
tad dskbufp
dac 9f+t+2
dac .+2
jms copy; ..; inode; 8
lac 9f+t
tad d8
jms betwen; d0; i.size
skp
jmp dget i
jms dacisize
dzm d.i
jmp dget i
dput: 0
lac 9f+t+1
jms dskrd
lac 9f+t+2
dac .+3
jms copy; inode; ..; 8
lac 9f+t+1
jms dskwr
jmp dput i
t = t+3 "** first t not there (hole from hole punch?)
pget: 0
lrss 6
dac 9f+t
lac i.flags
"** 01-s1.pdf page 37
and o200000
sza
jmp 2f
lac 9f+t
jms betwen; d0; d6
jmp 1f
tad idskpp
dac 9f+t
lac 9f+t i
sna
jms alloc
dac 9f+t i
jmp pget i
1:
jms alloc
dac 9f+t+1
jms copy; i.dskps; dskbuf; 7
jms copyz; dskbuf+7; 64-7 "** NUMBER UNCLEAR
lac 9f+t+1
jms dskwr
lac 9f+t+1
dac i.dskps
jms copyz; i.dskps+1; 6
lac i.flags
xor o200000
dac i.flags
2:
lac 9f+t
lrss 7
jms betwen; d0; d6
jms halt " file too big
tad idskpp
dac 9f+t+1
lac 9f+t+1 i
sna
jms alloc
dac 9f+t+1 i
dac 9f+t+2
jms dskrd
lac 9f+t
and o77
tad dskbufp
dac 9f+t+1
lac 9f+t+1 i
sza
jmp pget i
jms alloc
dac 9f+t
lac 9f+t+2
jms dskrd
lac 9f+t
jmp pget i
t = t+3
iwrite: 0
dac 9f+t
lac iwrite
"** 01-s1.pdf page 38
dac iread
lac cskp
dac iwrite
jmp 1f
iread: 0
dac 9f+t
lac cnop
dac iwrite
1:
-1
tad iread i
dac 10
dac 11
isz iread
lac iread i
dac 9f+t+1
isz iread
lac o70000
xct iwrite
lac i.size
cma
tad 9f+t
cma
jms betwen; d0; 9f+t+1
lac 9f+t+1
dac 9f+t+2
cma
tad d1
sna
jmp iread i
dac 9f+t+1
1:
lac 9f+t
jms pget
dac 9f+t+3
jms dskrd
lac 9f+t
and o77
tad dskbufp
tad dm1
xct iwrite
jmp .+3
dac 10
cskp:
skp
dac 11
2:
lac 11 i
dac 10 i
isz 9f+t
isz 9f+t+1
jmp 3f
xct iwrite
jmp 4f
lac 9f+t
jms betwen; d0; i.size
dac i.size
lac 9f+t+3
4:
"** 01-s1.pdf page 38
lac 9f+t+2
jmp iread i
3:
lac 9f+t
and o77
sza
jmp 2b
xct iwrite
jmp 1b
lac 9f+t+3
jms dskwr
jmp 1b
t = t+4
finac: 0
lac u.ac
jms fget
jms error
lac f.flags
sma
jms error
lac f.i
jms iget
jms finac i
dacisize: 0
dac i.size
jms iput
lac i.size
jmp dacisize i

368
scans/s7.s Normal file
View File

@@ -0,0 +1,368 @@
"** 01-s1.pdf page 41
" s7
pibreak:
dac .ac "** CROSSED OUT....
dpsf
jmp 1f
dpcf
dprs
dac dpstat
sma ral
jmp 2f
dprc
dac dpchar
-1
dac dpread
lac dpstat
ral
2:
sma
jmp piret
-1
dac dpwrite
jmp piret "** END OF CROSSOUT
1: clsf
jmp 1f
lpb
dac pbsflgs
isz s.tim+1
skp
isz s.tim
isz uquant
"** written: ttydelay -> ttyd1
"** written: ttyrestart -> ttyres1
cnop:
nop
-1
dac 7
clon
lac ttydelay
spa
isz ttydelay
skp
jms ttyrestart
lac .dspb "** START CROSSED OUT: written: lac tty
sna
jmp piret
isz .dsptm
skp
jmp dsprestart
sad d3
jmp piret
isz .dspb
jmp piret
jmp dsprestart "** END CROSSED OUT
1: dssf
jmp 1f
-1
dac .dskb
"** 01-s1.pdf page 42
dsrs
dac .dske
dscs
jmp piret
1: lds "** BEGIN CROSSED OUT
sma ral
jmp 1f
cdf
lac .dspb
sna
jmp piret
tad dm3
sna
jmp dsprestart
dac .dspb
jmp piret
dsprestart:
lac d1
dac .dspb
lac dspbufp
beg "** ???
-10
dac .dsptm
jmp piret
1: sna ral
jmp .+3
racf
jmp piret
sma
jmp 1f
lda
dac .lpba
rlpd
jmp piret
1: ksf
jmp 1f
lac ttydelay
sma
isz ttydelay
krb
dac char
sad o375
jmp intrp1
lac d1
jms putchar
dzm char
lac sfiles+0
jms wakeup
dac sfiles+0
lac char
sad o212
skp
jmp piret
lac sfiles+1
sma
xor o400000
dac sfiles+1
"** 01-s1.pdf page 43
jms putcr
jms ttyrestart
jmp piret
1: tsf
jmp 1f
tcf
jms ttyrestart
jmp piret
ttyrestart: 0
lac ttydelay
spa
jmp ttyrestart i
lac nttychar
dzm nttychar
sza
jmp 3f
isz ttydelay
lac d2
jms getchar
jmp 2f
3:
tls
sad o12
jms putcr
sad o15
skp
jmp ttyrestart i
lac ttydelay
tad o20
rcr
cma
dac ttydelay
jmp ttyrestart i
2:
lac sfiles+1
jms wakeup
dac sfiles+1
jmp ttyrestart i "** written arrow up 2 copies
1: sck "** BEGIN CROSSED OUT
jmp 1f
cck
lck
dac char
sad o33
jmp intrp2
lac d3
jms putchar
nop
lac sfiles+2
jms wakeup
dac sfiles+2
jmp piret
1: rsf
jmp 1f
"** 01-s1.pdf page 44
lac npptchar
sna
jmp .+5
dac char
rrb
dac npptchar
jmp .+3
rrb
dac char
3:
lac char
sna
jmp 2f
lac d4
jms putchar
jmp 3f
lac char
sad d4
jmp 4f
2:
lac npptchar
sna
jmp .+4
dac char
dzm npptchar
jmp 3b
rsa
lac sfiles+3
jms wakeup
xor o400000
dac sfiles+3
jmp piret
3:
lac char
dac npptchar
4:
lac sfiles+3
jms wakeup
dac sfiles+3
jmp piret
1: psf
jmp 1f
pcf
lac d5
jms getchar
jmp .+3
psa
jmp piret
lac sfiles+4
jms wakeup
dac sfiles+4
jmp piret
1: spb "** BEGIN CROSSED OUT
jmp 1f
cpb
lpb
dac pbsflgs+1
"** 01-s1.pdf page 45
and o2000
sna
jmp piret
jms dspinit
lac sfiles+6
jms wakeup
dac sfiles+6
cla
wbl
jmp piret "** END CROSSED OUT
1: crsf
jmp 1f
crrb
dac crchar
-1
dac crread
jmp piret
1: crrb
piret:
lac 0
ral
lac .ac
ion
jmp 0 i
wakeup: 0
dac 9f+t
-mnproc
dac 9f+t+1
lac tadu
dac 2f
lac dacu
dac 2f+1
1:
lac 9f+t
ral
dac 9f+t
sma
jmp 2f+2
lac o700000
2: tad ..
dac ..
lac 2b
tad d4
dac 2b
lac 2b+1
tad d4
dac 2b+1
isz 9f+t+1
jmp 1b
cla
jmp wakeup i
t = t+2
putcr: 0
lac o15
dac nttychar
"** 01-s1.pdf page 46
cla
jmp putcr i
intrp1:
lac d5
dac .int1
lac d1
jms getchar
skp
jmp .-3
lac d2
jms getchar
skp
jmp .-3
lac sfiles+0
jms wakeup
dac sfiles+0
lac sfiles+1
jms wakeup
dac sfiles+1
jms chkint
jmp piret
jmp 1f
intrp2:
lac d7
dac .int2
lac d3
jms getchar
skp
jmp .-3
lac sfiles+2
jms wakeup
dac sfiles+2
lac sfiles+6
jms wakeup
dac sfiles+6
jms chkint
jmp piret
1:
lac 0
dac 020
lac .ac
jmp 021

213
scans/s8.s Normal file
View File

@@ -0,0 +1,213 @@
"** 01-s1.pdf page 48
" s8
" manifests
mnproc = 10
dspbsz = 270
ndskbs = 4
" flags
.insys: 0
.int1: 0
.int2: 0
.ac: 0
.savblk: 0
.dsptm: 0
.dskb: 0
.dske: 0
" pointers
tadu: tad ulist
dacu: dac ulist
maxquant: 30
ofilesp: u.ofiles
idskpp: i.dskps
dskbufp: dskbuf
edspbuf: dspbuf+dspbsz
fblksp: s.fblks
dacq1: dac q1
lacq1: lac q1
q2p: q2
" strings
initf:
<i>n;<i>t;< > ;< > "
" constants
d0: 0
d1: 1
d2: 2
d3: 3
d4: 4
d5: 5
d6: 6
d7: o7: 07
d8: 8
d9: 9
o12: d10: 10
o14: 014
o15: 015
o17: 017
o20: 020
o33: 033
o40: 040
o55: 055
o77: 077
d65:o101: 0101
d33: 33
o132: 0132
o134: 0134
o137: 0137
o155: 0155
o177: 0177
"** 01-s1.pdf page 49
o212: 0212
o375: 0375
o777: 0777
o2000: 02000
o4000: 04000
d7999: 7999
o10000: 010000
o17762: 017762
o17777: 017777
o20001: 020001
o40000: 040000
o40001: 040001
o70000: 070000
o77777: 077777
o100000: 0100000
o140000: 0140000
o200000: 0200000
o200001: 0200001
o300000: 0300000
o400000: 0400000
o500000: 0500000
o577777: 0577777
o600000: 0600000
o640000: 0640000
o700000: 0700000
o777700: 0777700
o777760: 0777760
dm3: -3
dm1: -1
9: .=.+t
c1: .=.+1
q1: q2;q2+90
.=.+14
q2:
.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0
.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0
.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0
.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0
.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0;.+2;0
dsploc: .=.+1
dsplno: .=.+1
dspbuf:
0065057;0147740;0160000
.=.+30
coldentry:
dzm 0100 " not re-entrant
caf
ion
clon
law 3072
wcga
jms dspinit
law dspbuf
jms movdsp
cla
jms dskio; 06000
jms copy; dskbuf; sysdata; ulist-sysdata
lac d3
jms namei; initf
jms halt
"** 01-s1.pdf page 50
jms iget
cla
jms iread; 4096; 4096
jmp 4096
. = dspbuf+dspbsz+3
dskbuf = 07700
dskbs: .=.+65+65+65+65
edskbsp: .
uquant: .=.+1
dspbufp: .=.+1
pbsflgs: .=.+2
mode: .=.+1
nttychar: .=.+1
npptchar: .=.+1
ttydelay: .=.+1
name: .=.+4
lnkaddr: .=.+1
char: .=.+1
dskaddr: .=.+1
uniqpid: 1
lu: .=.+4
sfiles: .=.+10
dpdata:
dpstat: .=.+1
dpread: .=.+1
dpwrite: .=.+1
dpchar: .=.+1
dspdata:
.dspb: .=.+1
.lpba: .=.+1 "** 4 written on listing
crdata:
crread: .=.+1
crchar: .=.+1
sysdata:
s.nxfblk: .=.+1
s.nfblks: .=.+1
s.fblks: .=.+10
s.uniq: .=.+1
s.tim: .=.+2
ulist:
0131000;1;0;0
0031040;0;0;0
0031100;0;0;0
0031140;0;0;0
0031200;0;0;0
0031240;0;0;0
0031300;0;0;0
0031340;0;0;0
0031400;0;0;0
0031440;0;0;0
userdata:
u.ac: 0
u.mq: 0
u.rq: .=.+9
u.uid: -1
u.pid: 1
u.cdir: 3
u.ulistp: ulist
u.swapret: 0
u.base: 0
u.count: 0
"** 01-s1.pdf page 51
u.limit: 0
u.ofiles: .=.+30
u.dspbuf: 0
u.intflg: 1
.=userdata+64
ii: .=.+1
inode:
i.flags: .=.+1
i.dskps: .=.+7
i.uid: .=.+1
i.nlks: .=.+1
i.size: .=.+1
i.uniq: .=.+1
.= inode+12
di: .=.+1
dnode:
d.i: .=.+1
d.name: .=.+4
d.uniq: .=.+1
. = dnode+8
fnode:
f.flags: .=.+1
f.badd: .=.+1
f.i: 0

117
scans/s9.s Normal file
View File

@@ -0,0 +1,117 @@
"** 01-s1.pdf page 53
" s9 -- cold boot
. = coldentry+4
" zero i-list
dzm ii
jms copyz; dskbuf; 64
1:
lac ii
jms dskio; 0700
isz ii
-710
tad ii
jmp 1b
" free rest of disk
1:
lac ii
jms free
isz ii
-6400
tad ii
sza
jmp 1b
" read in tapes
dzm ii
1:
dzm sum
jms getw " count
sza
jmp .+3
hlt
jmp 1b " 0 count means pause
dac xx
isz ii
lac ii
jms iget
jms copyz; inode; 12
jms getw " flags
dac i.flags
-1
dac i.uid
jms getw " number links
dac i.nlks
-2
tad xx
dac i.size
lac ii
dac i.uniq
law 4096-1
dac 8
-1
tad i.size
cma
sna
jmp 3f
dac xx
"** 01-s1.pdf page 54
2:
jms getw
dac 8 i
isz xx
jmp 2b
3:
lac sum
dac xx
jms getw " checksum
sad xx
skp
jms halt
lac i.size
dac .+4
cla
jms iwrite; 4096; ..
jms iput
cla
jms dskio
; 07000 "** writing on listing
jmp 1b
getw: 0
jms getc
alss 12
lmq
jms getc
omq
lmq
jms getc
omq
lmq
add sum
dac sum
lacq
jmp getw i
getc: 0
iof
rsa
rsf
jmp .-1
rrb
sna
jmp getc+1
and o77
ion
jmp getc i
xx: 0
sum: 0

97
scans/sop.s Normal file
View File

@@ -0,0 +1,97 @@
"** 01-s1.pdf page 62
" sop
dac = 0040000
jms = 0100000
dzm = 0140000
lac = 0200000
xor = 0240000
add = 0300000
tad = 0340000
xct = 0400000
isz = 0440000
and = 0500000
sad = 0540000
jmp = 0600000
nop = 0740000
i = 020000
law = 0760000
cma = 0740001
las = 0750004
ral = 0740010
rar = 0740020
hlt = 0740040
sma = 0740100
sza = 0740200
snl = 0740400
skp = 0741000
sna = 0741200
szl = 0741400
rtl = 0742010
rtr = 0742020
cil = 0744000
rcl = 0744010
rcr = 0744020
cia = 0750000
lrs = 0640500
lrss = 0660500
lls = 0640600
llss = 0660600
als = 0640700
alss = 0660700
mul = 0653323
idiv = 0653323
lacq = 0641002
clq = 0650000
omq = 0650002
cmq = 0650004
lmq = 0652000
dscs = 0707141
dslw = 0707124
dslm = 0707142
dsld = 0707104
dsls = 0707144
dssf = 0707121
dsrs = 0707132
iof = 0700002
ion = 0700042
caf = 0703302
clon = 0700044
clsf = 0700001
"** 01-s1.pdf page 63
clof = 0700004
ksf = 0700301
krb = 0700312
tsf = 0700401
tcf = 0700402
tls = 0700406
sck = 0704301
cck = 0704304
lck = 0704312
rsf = 0700101
rsa = 0700104
rrb = 0700112
psf = 0700201
pcf = 0700202
psa = 0700204
cdf = 0700501
lds = 0701052
lda = 0701012
wcga = 0704206
raef = 0700742
rlpd = 0700723
beg = 0700547
spb = 0704401
cpb = 0704404
lpb = 0704412
wbl = 0704424
dprs = 0704752
dpsf = 0704741
dpcf = 0704761
dprc = 0704712
crsf = 0706701
crrb = 0706712

4
scans/sx.s Normal file
View File

@@ -0,0 +1,4 @@
" For now, this stuff is defined so that
" the assembler doesn't complain about it
o7000: 07000

40
scans/trysys.s Normal file
View File

@@ -0,0 +1,40 @@
"** 01-s1.pdf page 65
" trysys
sys open; a.out; 0
spa
jmp error
sys read; buf; 3072
sad .-1
jmp error
iof
caf
cdf
clof
law buf
dac t1
dzm t2
-3072
dac c1
1:
lac t1 i
dac r2 i
isz t1
isz r2
isz c1
jmp 1b
jmp 0100
error:
lac d1
sys write; 1f; 1
sys exit
1: 077012
a.out:
<a.>;<ou><t 040; 040040
t1: 0
t2: 0
c1: 0
d1: 1
buf:

View File

@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# A7out: user-mode simulator for PDP-7 Unix applications
# a7out: user-mode simulator for PDP-7 Unix applications
#
# (c) 2016 Warren Toomey, GPL3
#
@@ -11,7 +11,7 @@ use Data::Dumper;
### Global variables ###
my $debug = 0; # Debug flag
my @Mem; # 8K 18-bit words of main memory
my @FD; # Array of open filehandles
my @FD; # Array of open filehandles
# Registers
my $PC = 0; # Program counter
@@ -27,11 +27,14 @@ if ( ( @ARGV > 0 ) && ( $ARGV[0] eq "-d" ) ) {
}
# Check the arguments
die("Usage: $0 [-d] a.outfile\n") if ( @ARGV != 1 );
die("Usage: $0 [-d] a.outfile [arg1 arg2 ...]\n") if ( @ARGV < 1 );
# Load the a.out file into memory
# and simulate it
load_code( $ARGV[0] );
load_code( shift(@ARGV) );
set_arguments(@ARGV);
#dump_memory();
#exit(0);
simulate();
exit(0);
@@ -47,6 +50,7 @@ sub load_code {
# Set up two file open filehandles
$FD[0] = \*STDIN;
$FD[1] = \*STDOUT;
$FD[8] = \*STDERR; # According to cat.s (uses d8 == 8)
# Open up the file
open( my $IN, "<", $filename ) || die("Unable to open $filename: $!\n");
@@ -67,6 +71,62 @@ sub load_code {
close($IN);
}
### Copy the arguments into the PDP-7 memory space, and build
### an array of pointers to these arguments. Build a pointer
### at 017777 that points at the array.
###
### At the moment, this is NOT what PDP-7 Unix uses, but it's
### a start and it will help us to grok the real thing.
###
### For now, assume abc, def and ghi are stored in memory.
### The layout of the pointers and strings would be:
###
### +-------+
### | |
### | +-----|---------+
### | | | |
### | | +---|---------|---------+
### | | | | | |
### | | | V V V
### |o|o|o|0|<ab>|<c 0|<de>|<f 0|<gh>|<i 0|o|
### ^ |
### | |
### +-------------------------------------+
### 0 0 0 0 0 0 0 0 0 0 0
### 1 1 1 1 1 1 1 1 1 1 1
### 7 7 7 7 7 7 7 7 7 7 7
### 7 7 7 7 7 7 7 7 7 7 7
### 6 6 6 7 7 7 7 7 7 7 7
### 5 6 7 0 1 2 3 4 5 6 7
###
sub set_arguments {
# No arguments, set the 017777 pointer to 017776 which is NULL
if (@ARGV==0) {
$Mem[ 017777 ] = 017776;
dprintf("No arguments, so NULL 017777 pointer\n");
return;
}
# Count the number of words to store each string and its pointer
my $wordcount=2; # 2 as we count the NULL pointer at end of array
my $argcount= @ARGV;
foreach my $arg (@ARGV) {
# +1 before /2 to allow for the NUL character at end of string
# += +1 to include the pointer to the string
$wordcount += 1 + ( (length($arg) +1)/2);
}
my $arraybase= 017777 - $wordcount;
my $stringbase= $arraybase + $argcount + 1; # include NULL pointer
$Mem[ 017777 ] = $arraybase;
# Now copy each string into memory and initialise the pointer
foreach my $arg (@ARGV) {
$Mem[$arraybase++]= $stringbase;
$stringbase= string2mem($arg, $stringbase);
}
}
### Simulate the machine code loaded into memory
sub simulate {
@@ -74,6 +134,8 @@ sub simulate {
my %Oplist = (
oct("004") => \&dac,
oct("020") => \&lac,
oct("034") => \&tad,
oct("060") => \&jmp,
oct("070") => \&iot,
oct("074") => \&special,
);
@@ -86,18 +148,19 @@ sub simulate {
my $opcode = ( $instruction >> 12 ) & 074;
my $indirect = ( $instruction >> 13 ) & 1;
my $addr = $instruction & 017777;
#printf( "PC %06o: instruction %08o, op %03o, ind %o, addr %06o\n",
# $PC, $instruction, $opcode, $indirect, $addr )
# if ($debug);
# Work out what any indirect address would be
my $indaddr= ($indirect) ? $Mem[$addr] & 017777 : $addr;
dprintf( "PC %06o: instr %06o, op %03o, ind %o, addr %06o ind %06o\n",
$PC, $instruction, $opcode, $indirect, $addr, $indaddr );
# Simulate the instruction. Each subroutine updates the $PC
if ( defined( $Oplist{$opcode} ) ) {
$Oplist{$opcode}->( $instruction, $indirect, $addr );
}
else {
printf( "Unknown instruction 0%o at location 0%o\n",
$Oplist{$opcode}->( $instruction, $addr, $indaddr );
} else {
printf( STDERR "Unknown instruction 0%o at location 0%o\n",
$instruction, $PC );
die("\n");
exit(1);
}
}
}
@@ -105,34 +168,44 @@ sub simulate {
# Debug code: dump memory contents
sub dump_memory {
foreach my $i ( 0 .. 017777 ) {
printf( "%06o: %08o\n", $i, $Mem[$i] ) if ( $Mem[$i] != 0 );
printf( STDERR "%06o: %06o\n", $i, $Mem[$i] ) if ( $Mem[$i] != 0 );
}
}
# Load AC
sub lac {
my ( $instruction, $indirect, $addr ) = @_;
printf( "PC %06o: lac %05o (value %08o) into AC\n",
$PC, $addr, $Mem[$addr] )
if ($debug);
$AC = ($indirect) ? $Mem[ $Mem[$addr] & 017777 ]: $Mem[$addr];
my ( $instruction, $addr, $indaddr ) = @_;
dprintf( "PC %06o: lac %05o (value %06o) into AC\n",
$PC, $indaddr, $Mem[$indaddr] );
$AC = $Mem[$indaddr];
$PC++;
}
# Deposit AC
sub dac {
my ( $instruction, $indirect, $addr ) = @_;
printf( "PC %06o: dac AC (value %08o) into %05o into AC\n",
$PC, $AC, $addr )
if ($debug);
if ($indirect) {
$Mem[ $Mem[$addr] & 017777 ] = $PC;
} else {
$Mem[$addr] = $AC;
}
my ( $instruction, $addr, $indaddr ) = @_;
dprintf( "PC %06o: dac AC (value %06o) into %05o\n",
$PC, $AC, $indaddr );
$Mem[$indaddr] = $AC;
$PC++;
}
# Add to AC
sub tad {
my ( $instruction, $addr, $indaddr ) = @_;
dprintf( "PC %06o: tac AC (value %06o) from addr %05o\n",
$PC, $AC, $indaddr );
$AC+= $Mem[$indaddr];
$PC++;
}
# Jump
sub jmp {
my ( $instruction, $addr, $indaddr ) = @_;
dprintf( "PC %06o: jmp %06o\n", $PC, $indaddr );
$PC = $indaddr;
}
# Special instructions
sub special {
my $instruction = shift;
@@ -140,15 +213,33 @@ sub special {
# Deal with each one in turn
# hlt
if ( $instruction == 0740040 ) {
printf( "PC %06o: program halted\n", $PC );
printf( STDERR "PC %06o: program halted\n", $PC );
dump_memory() if ($debug);
exit(1);
}
if ( $instruction == 0741100 ) { # spa: skip on positive AC
dprintf( "PC %06o: spa AC %06o\n", $PC, $AC );
# Because we are dealing with 18 bits, compare the range
$PC += ( ($AC >= 0) && ($AC < 0400000) ) ? 2 : 1;
return;
}
if ( $instruction == 0741200 ) { # sna: skip on non-zero AC
dprintf( "PC %06o: sna AC %06o\n", $PC, $AC );
$PC += ( $AC != 0 ) ? 2 : 1;
return;
}
if ( $instruction == 0740200 ) { # sza: skip on zero AC
dprintf( "PC %06o: sza AC %06o\n", $PC, $AC );
$PC += ( $AC == 0 ) ? 2 : 1;
return;
}
printf( STDERR "PC %06o: unknown instruction %06o\n", $PC, $instruction );
exit(1);
}
# I/O transfer: used for system calls
sub iot {
my ( $instruction, $indirect, $addr ) = @_;
my ( $instruction, $addr, $indaddr ) = @_;
# Syscalls that we can simulate
my %Syscallist = (
@@ -163,190 +254,236 @@ sub iot {
if ( defined( $Syscallist{$addr} ) ) {
$Syscallist{$addr}->();
} else {
printf( "PC %06o: Unknown syscall %d\n", $PC, $addr );
die("\n");
printf( STDERR "PC %06o: Unknown syscall %d\n", $PC, $addr );
exit(1);
}
}
# Exit system call
sub sys_exit {
printf("PC %06o: exit system call\n", $PC) if ($debug);
exit(0);
dprintf( "PC %06o: exit system call\n", $PC );
exit(0);
}
# Close system call
sub sys_close {
# AC is the file descriptor
my $fd= $AC;
printf("PC %06o: close: closing fd %d\n", $PC, $fd) if ($debug);
# Bump up the PC
$PC += 1;
# AC is the file descriptor
my $fd = $AC;
dprintf( "PC %06o: close: closing fd %d\n", $PC, $fd );
# That filehandle is not open, set an error -1 in octal
if (!defined($FD[$fd])) {
print("close: fd $fd is not open\n") if ($debug);
$AC= 0777777; return;
}
close($FD[$fd]);
$FD[$fd]= undef;
$AC=0; return;
# Bump up the PC
$PC += 1;
# That filehandle is not open, set an error -1 in octal
if ( !defined( $FD[$fd] ) ) {
dprint( "close: fd $fd is not open\n");
$AC = 0777777;
return;
}
close( $FD[$fd] );
$FD[$fd] = undef;
$AC = 0;
return;
}
# Open system call
sub sys_open {
# Open seems to have arguments: PC+1 has a pointer to the filename,
# PC+2 and PC+3 I don't know yet, probably read/write and mask?
# AC is the opened fd on success, or -1 on error
# Get the start address of the string
my $start= $Mem[$PC+1];
# Open seems to have arguments: PC+1 has a pointer to the filename,
# PC+2 and PC+3 I don't know yet, probably read/write and mask?
# AC is the opened fd on success, or -1 on error
# Bump up the PC
$PC += 4;
# Get the start address of the string
my $start = $Mem[ $PC + 1 ];
# Convert this to a sensible ASCII filename
my $filename= mem2string($start);
printf("PC %06o: open: file %s\n", $PC, $filename) if ($debug);
# Bump up the PC
$PC += 4;
# Open the file
if (open(my $FH, "<", $filename)) {
# Find a place in the @FD array to store this filehandle. 99 is arbitrary
my $fd;
foreach $fd (0 .. 99) {
if (!defined($FD[$fd])) {
$FD[$fd]= $FH; last;
}
# Convert this to a sensible ASCII filename
my $filename = mem2string($start);
dprintf( "PC %06o: open: file %s\n", $PC, $filename );
# Open the file
if ( open( my $FH, "<", $filename ) ) {
# Find a place in the @FD array to store this filehandle. 99 is arbitrary
foreach my $fd ( 0 .. 99 ) {
if ( !defined( $FD[$fd] ) ) {
$FD[$fd] = $FH;
$AC = $fd;
last;
}
}
return;
} else {
# No filehandle, so it's an error
dprintf( "open failed: $!\n");
$AC = 0777777;
return;
}
$AC=$fd; return;
} else {
# No filehandle, so it's an error
print("open failed: $!\n") if ($debug);
$AC= 0777777; return;
}
}
# Read system call
sub sys_read {
# Read seems to have arguments: AC is the file descriptor, PC+1 is
# the pointer to the buffer and PC+2 is the number of words to read.
# Return the number of words read in AC on success, or -1 on error.
# Get the file descriptor, start address and end address
my $fd= $AC;
my $start= $Mem[$PC+1];
my $count= $Mem[$PC+2];
my $end= $start + $count -1;
printf("PC %06o: read: %d words from %o from fd %d\n", $PC, $count, $start, $fd) if ($debug);
# Read seems to have arguments: AC is the file descriptor, PC+1 is
# the pointer to the buffer and PC+2 is the number of words to read.
# Return the number of words read in AC on success, or -1 on error.
# Bump up the PC
$PC += 3;
# Get the file descriptor, start address and end address
my $fd = $AC;
my $start = $Mem[ $PC + 1 ];
my $count = $Mem[ $PC + 2 ];
my $end = ($start + $count - 1) & 017777;
die("sys_read: bad start/end addresses $start $end\n") if ($end < $start);
dprintf( "PC %06o: read: %d words into %o from fd %d\n",
$PC, $count, $start, $fd );
# That filehandle is not open, set an error -1 in octal
if (!defined($FD[$fd])) {
print("read: fd $fd is not open\n") if ($debug);
$AC= 0777777; return;
}
# Bump up the PC
$PC += 3;
# Read each word in
my $FH= $FD[$fd];
$count=0;
foreach my $addr ($start .. $end) {
# It's a terminal, so convert from ASCII
if (-t $FH) {
my $c1= getc($FH);
last if (!defined($c1)); # No character, leave the loop
my $c2= getc($FH) || ""; # No character, make it a NUL
$Mem[$addr]= (ord($c1) << 9) | ord($c2); # Pack both into one word
$count++;
} else {
# otherwise (for now) read in one line and convert to octal
my $line= <$FH>;
chomp($line);
last if (!defined($line)); # No line, leave the loop
$Mem[$addr]= oct($line) & 0777777;
$count++;
# That filehandle is not open, set an error -1 in octal
if ( !defined( $FD[$fd] ) ) {
dprint( "read: fd $fd is not open\n");
$AC = 0777777;
return;
}
}
# No error
$AC= $count; return;
# Read each word in
my $FH = $FD[$fd];
$count = 0;
foreach my $addr ( $start .. $end ) {
# It's a terminal, so convert from ASCII
if ( -t $FH ) {
my $c1 = getc($FH);
last if ( !defined($c1) ); # No character, leave the loop
my $c2 = getc($FH) || ""; # No character, make it a NUL
$Mem[$addr] =
( ord($c1) << 9 ) | ord($c2); # Pack both into one word
$count++;
} else {
# otherwise (for now) read in one line and convert to octal
my $line = <$FH>;
last if ( !defined($line) ); # No line, leave the loop
chomp($line);
$Mem[$addr] = oct($line) & 0777777;
$count++;
}
}
# No error
$AC = $count;
return;
}
# Write system call
sub sys_write {
# Write seems to have arguments: AC is the file descriptor, PC+1 is
# the pointer to the buffer and PC+2 is the number of words to write
# Write seems to have arguments: AC is the file descriptor, PC+1 is
# the pointer to the buffer and PC+2 is the number of words to write
# Get the file descriptor, start address and end address
my $fd= $AC;
my $start= $Mem[$PC+1];
my $count= $Mem[$PC+2];
my $end= $start + $count -1;
printf("PC %06o: write: %d words from %o to fd %d\n", $PC, $count, $start, $fd) if ($debug);
# Get the file descriptor, start address and end address
my $fd = $AC;
my $start = $Mem[ $PC + 1 ];
my $count = $Mem[ $PC + 2 ];
my $end = ($start + $count - 1) & 017777;
die("sys_write: bad start/end addresses $start $end\n") if ($end < $start);
dprintf( "PC %06o: write: %d words from %o to fd %d\n",
$PC, $count, $start, $fd );
# Bump up the PC
$PC += 3;
# Bump up the PC
$PC += 3;
# That filehandle is not open, set an error -1 in octal
if (!defined($FD[$fd])) {
print("write: fd $fd is not open\n") if ($debug);
$AC= 0777777; return;
}
# Write each word out
my $FH= $FD[$fd];
foreach my $addr ($start .. $end) {
# It's a terminal, so convert to ASCII
# otherwise (for now) print in octal
if (-t $FH) {
print($FH word2ascii($Mem[$addr]));
} else {
printf($FH "%06o\n", $Mem[$addr]);
# That filehandle is not open, set an error -1 in octal
if ( !defined( $FD[$fd] ) ) {
dprint( "write: fd $fd is not open\n");
$AC = 0777777;
return;
}
}
# No error
$AC= 0; return;
# Write each word out
my $FH = $FD[$fd];
foreach my $addr ( $start .. $end ) {
# It's a terminal, so convert to ASCII
# otherwise (for now) print in octal
if ( -t $FH ) {
print( $FH word2ascii( $Mem[$addr] ) );
} else {
printf( $FH "%06o\n", $Mem[$addr] );
}
}
# No error
$AC = 0;
return;
}
# Convert an 18-bit word into two ASCII characters and return them.
# Don't return NUL characters
sub word2ascii {
my $word= shift;
my $c1= ($word >> 9) & 0177;
my $c2= $word & 0177;
my $result= "";
$result .= chr($c1) if ($c1);
$result .= chr($c2) if ($c2);
return($result);
my $word = shift;
my $c1 = ( $word >> 9 ) & 0177;
my $c2 = $word & 0177;
my $result = "";
$result .= chr($c1) if ($c1);
$result .= chr($c2) if ($c2);
return ($result);
}
# Given the address of a word in memory, interpret that location
# and those following as a NUL-terminated ASCII string and return
# a copy of this string
sub mem2string {
my $addr= shift;
my $result= "";
my $addr = shift;
my $result = "";
while (1) {
# Stop when the address leave the 8K word address space
return($result) if ($addr > 017777);
while (1) {
# Stop when the value there is zero
my $word= $Mem[$addr];
return($result) if ($word==0);
# Stop when the address leave the 8K word address space
return ($result) if ( $addr > 017777 );
# Get the top ASCII character, return if NUL
my $c1= ($word >> 9) & 0177;
return($result) if ($c1==0);
$result .= chr($c1);
# Stop when the value there is zero
my $word = $Mem[$addr];
return ($result) if ( $word == 0 );
# Get the bottom ASCII character, return if NUL
my $c2= $word & 0177;
return($result) if ($c2==0);
$result .= chr($c2);
# Get the top ASCII character, return if NUL
my $c1 = ( $word >> 9 ) & 0177;
return ($result) if ( $c1 == 0 );
$result .= chr($c1);
# Move up to the next address
$addr++;
}
# Get the bottom ASCII character, return if NUL
my $c2 = $word & 0177;
return ($result) if ( $c2 == 0 );
$result .= chr($c2);
# Move up to the next address
$addr++;
}
}
# Given a string and the address of a word in memory, copy
# the string into memory starting at that address and NUL
# terminate the string. Return the first address after the string.
#
# We will go off the end of the string: suppress warnings
no warnings ('substr');
sub string2mem {
my ($str, $base)= @_;
# <= length so we go off the end and insert a NUL
for (my $i=0; $i <= length($str); $i += 2) {
my $c1= substr($str, $i, 1) || "";
my $c2= substr($str, $i+1, 1) || "";
#printf("Saving %06o to %05o\n", (ord($c1) << 9 ) | ord($c2), $base);
$Mem[$base++]= (ord($c1) << 9 ) | ord($c2);
}
return($base);
}
# Print out debug messages
sub dprintf {
printf( STDERR @_) if ($debug);
}

View File

@@ -21,6 +21,8 @@ my $origline; # The current input line of code
my $stage = 1; # Pass one or pass two
my $debug = 0; # Run in debug mode
my $errors = 0; # set to non-zero on error
my %Undef; # undefined symbols: only complain once
### Main program ###
@@ -87,13 +89,25 @@ for my $i ( 0 .. $#Mem ) {
}
}
exit(0);
exit($errors);
my $file; # global for error messages
my $lineno;
sub err {
my $msg = shift;
$errors = 1; # exit status
print STDERR "$file:$lineno: $msg\n";
return 0;
}
# Open and parse the given file
sub parse_file {
my $file = shift;
$file = shift;
open( my $IN, "<", $file ) || die("Cannot read $file: $!\n");
$lineno = 0;
while ( my $line = <$IN> ) {
$lineno++;
# Lose the end of line and any leading/trailing whitespace
# Discard any comments and preceding comment whitespace
@@ -116,7 +130,7 @@ sub parse_file {
my $labelsect = $1;
my $statement = $2;
#print(">$labelsect< >$statement<\n");
#print(">$labelsect< >$statement<\n");
# Split $labelsect into labels using the : character
my @labellist = split( /:\s*/, $labelsect );
@@ -147,9 +161,9 @@ sub parse_label {
}
# It's a textual label, check if it's been defined before
die("Label $label defined multiple times\n")
if ( defined( $Label{$label} ) );
if ( defined( $Label{$label} ) ) {
err("Label $label defined multiple times\n") if ( $stage == 1 );
}
# Otherwise, save its value
$Label{$label} = $Var{'.'};
#printf( "Set absolute label %s to 0%o\n", $label, $Label{$label} );
@@ -426,7 +440,11 @@ sub parse_expression {
#print("Did a subtraction and got $diff\n");
return ($diff);
}
die("I have no idea what $expression is in pass two\n") if ( $stage == 2 );
if ( $stage == 2 ) {
err("undefined: $expression") unless (defined $Undef{$expression});
$Undef{$expression} = 1;
}
return 0;
}
# Add two expression together
@@ -463,18 +481,20 @@ sub find_relative_label {
my $curlocation = $Var{'.'};
# Error check: no labels at all
die("No relative labels\n") if ( !defined( $Rlabel{$label} ) );
if ( !defined( $Rlabel{$label} ) ) {
return err("relative label $label not defined\n");
}
# Get the list of possible locations for this label
my $locarray = $Rlabel{$label};
# Error check: no locations
die("No relative labels\n") if ( @{$locarray} == 0 );
return err("No relative labels") if ( @{$locarray} == 0 );
# Error check: forward but no next location, or backward but no previous
die("No forward label\n")
return err("No forward label $label")
if ( ( $direction eq 'f' ) && ( $curlocation > $locarray->[-1] ) );
die("No backward label\n")
return err("No backward label $label")
if ( ( $direction eq 'b' ) && ( $curlocation < $locarray->[0] ) );
# Search forward for a location larger then the current one

123
tools/wktcat.s Normal file
View File

@@ -0,0 +1,123 @@
" Warren's cat program: cat [arg1 arg2 ...]
"
" Because the a7out simulator currently doesn't deal with ASCII files,
" here is how you can test it:
" ./as7 wktcat.s > a.out
"
" ./a7out a.out > z1
" <type some lines and end in ctrl-D>
"
" ./a7out a.out z1 z1
" <the text you typed in will be displayed twice>
"
" Also, the current coding is hideous and needs refactoring.
" I'm still coming to grips with PDP-7 assembly code.
main:
" Load the pointer pointer in 017777 to see if we have any arguments
lac 017777 i
sza " No args, so copy stdin to stdout
jmp catfiles " Yes args, so deal with them below
" This section copies from standard input to standard output
stdinout:
" Read five words into the buffer from stdin
" Five was chosen arbitrarily
lac d0
sys read; buf; 5
spa " Skip if result was >= 0
jmp error " Result was -ve, so error result
sna " Skip if result was >0
jmp end " Result was zero, so nothing left to read
" Save the count of words read in
dac 1f
" Write five words from the buffer to stdout
lac d1
sys write; buf; 1:0
" and loop back for more words to read
jmp stdinout
" This section opens files, and copies their contents to standard output
catfiles:
" We start with AC pointing to an argument. Save it at label 1f
dac name
" Open the file and get the fd into AC
sys open; name:0; 0; 0
spa
jmp badfile " Bad fd, exit with an error message
dac fd " Save the file descriptor
fileloop:
" Read five words into the buffer from the input file
lac fd
sys read; buf; 5
spa " Skip if result was >= 0
jmp error " Result was -ve, so error result
sna " Skip if result was >0
jmp fileend " Result was zero, so nothing left to read
" Save the count of words read in
dac 1f
" Write five words from the buffer to stdout
lac d1
sys write; buf; 1:0
" and loop back for more words to read
jmp fileloop
fileend:
" Close the open file descriptor
lac fd
sys close
" Load and increment the 017777 pointer
lac 017777
tad d1
dac 017777
" Load the pointer pointer in 017777 to see if we have any more arguments
lac 017777 i
sna " No args, so end the program
jmp end
jmp catfiles " Otherwise loop back to cat this file
end:
" exit
sys exit
" This code comes from the real cat.s
badfile:
lac name " Get the pointer to the filename
dac 1f " Store it in 1f below
lac d8 " Load fd 8 which is stderr
sys write; 1:0; 4 " Write the name, max 4 words
lac d8 " Then write " ?\n"
sys write; 1f; 2
sys exit " and exit
1: 040; 077012
error:
" Print an "err read" string and exit
lac d1
sys write; noreadstr; 5
sys exit
noreadstr:
<er>;<r 040;<re>;<ad>;012000
fd: 0 " fd of the open file
d0: 0 " Constants 0 and 1
d1: 1
d8: 8 " stderr seems to have fd 8
" Input buffer for read
buf: 0; 0; 0; 0; 0