1
0
mirror of https://github.com/livingcomputermuseum/pdp7-unix.git synced 2026-02-11 10:45:26 +00:00

added existing pdp7 files that parse properly

This commit is contained in:
Tom Everett
2016-03-05 15:21:44 -07:00
parent bc81cca976
commit 0811195212
12 changed files with 3027 additions and 434 deletions

View File

@@ -62,9 +62,15 @@ argument
;
assignment
: (opcode | variable | LOC | RELOC) '=' expression
: symbol '=' expression
;
// note that opcodes can be symbols. This is because it is legal to have a
// variable name that is an opcode
symbol
: opcode | variable | LOC | RELOC
;
expression
: multiplyingExpression ((PLUS | MINUS) multiplyingExpression)*
;
@@ -76,6 +82,7 @@ multiplyingExpression
atom
: variable
| LOC
| CHAR
| RELOC
| string
| DECIMAL
@@ -251,22 +258,22 @@ DECIMAL
: 'd' [0-9] +
;
OCTAL
: 'o' [0-7] +
;
DECIMAL_MINUS
: 'dm' [0-9] +
;
STRING
: '<' [a-zA-Z0-9$*,%/:?]*
;
CHAR
: [a-zA-Z0-9>.] '>'
;
COMMENT
: '"' ~ [\r\n]*
;

File diff suppressed because it is too large Load Diff

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
dtrace: 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

View File

@@ -0,0 +1,433 @@
" bi
start:
jms initio
-1
tad .main
dac pc
fetch:
lac pc i
lmq
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 t1 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
lac 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
lmq
lac dp
dac t1 i
lac t1
dac dp
isz t1
lac 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 8
skp
jmp 1b
lac ap i
lmq
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
uadr:
lac t1
dac t3 i
jmp fetch
umin:
-1
tad t1 i
cma
dac t3 i
jmp fetch
uind:
lac t1 i
dac t2 i
jmp fetch
unot:
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
y = x+a
d1: 1
dm1: -1
dm2: -2
o17777: 017777
t1: 0
t2: 0
t3: 0
t4: 0
addr: 0
pc = 017
sp: stack
dp: stack
ap: stack
stack: 0

View File

@@ -3,22 +3,22 @@
.. = 0
t = 0
orig:
hlt
jmp pibreak
hlt " overwritten with interrupt return addr
jmp pibreak " dispatch to interrupt processing
. = orig+7
-1
-1 " only ever set (to -1): never read?!
. = orig+020
1f
iof
dac u.ac
lac 020
dac 1f
. = orig+020 " syscall (CAL) processing
1f " addr for "CAL I": store return here on "CAL"
iof " interrupts off
dac u.ac " save user AC
lac 020 " save user return addr
dac 1f " save as if "CAL I"
lac 1f-1
dac 020
lac u.ac
jmp 1f+1
dac 020 " restore location 20
lac u.ac " restore user AC
jmp 1f+1 " join "CAL I" processing
1f
1: 0
iof " interrupts off
@@ -49,7 +49,7 @@ orig:
jmp .. i " dispatch system call
. = orig+0100
jmp coldentry
jmp coldentry " here to start kernel
jms halt
okexit:
@@ -64,9 +64,9 @@ sysexit: " common system call exit code
jms dskio; 07000 " save to disk?
1:
dzm .insys " clear "in system call" flag
jms chkint
skp
jmp .save " dump core??
jms chkint " pending interrupt?
skp " no
jmp .save " yes: dump core
jms copy; u.rq+2; 10; 6 " restore auto-index locations 10-15
lac u.rq+1 " restore auto-index location 9
dac 9
@@ -77,6 +77,7 @@ sysexit: " common system call exit code
lac u.ac " restore AC register
jmp u.rq+8 i " return to user
" scheduler / idle loop
swap: 0
ion
1:
@@ -84,49 +85,49 @@ swap: 0
jmp 1f
jms lookfor; 1 " in/ready
skp
jmp 1b
dzm maxquant
jmp 1b " loop until a process becomes ready
dzm maxquant " here with in/ready (self?)
jmp 3f
1:
dac 9f+t
jms lookfor; 2 " in/notready
1: " here with out/ready process
dac 9f+t " save process pointer (swapped out) in t0
jms lookfor; 2 " in/notready " find a swapped in process to swap out?
jmp 1f
jms lookfor; 1 " in/ready
jmp 1f
jmp 2f
1:
lac swap
dac u.swapret
dac u.swapret " return to scheduler when swapped back
iof
lac o200000
lac o200000 " change status to swapped out
tad u.ulistp i
dac u.ulistp i
ion
jms dskswap; 07000
jms dskswap; 07000 " swap process out
lac u.dspbuf
sna
jmp 2f
law dspbuf
jms movdsp
2:
iof
lac o600000
iof " disable interrupts
lac o600000 " change status (1->7?)
tad 9f+t i
dac 9f+t i
ion
jms dskswap; 06000
lac u.swapret
dac swap
lac o20
ion " enable interrupts
jms dskswap; 06000 " read process in?
lac u.swapret " set our return addr
dac swap " to saved return addr
lac o20 " reset maxquant to 16 ticks
dac maxquant
lac u.dspbuf
sza
sza " using display?
"** 01-s1.pdf page 4
jms movdsp
jms movdsp " yes.
3:
dzm uquant
dzm uquant " no. reset process tick count
iof
jmp swap i
jmp swap i " return
t = t+1
swp: " system call dispatch table
@@ -138,12 +139,18 @@ swp: " system call dispatch table
swn:
.-swp-1 i " count of system calls, plus indirect!
" AC/ new value for intflg (non-zero to ignore interrupt char)
" sys intrp
.intrp:
lac u.ac
dac u.intflg
jmp okexit
.sysloc: " "sysloc": syscall to return system addresses
" syscall to retrieve system addresses (data & routines!!)
" AC/ index (1..17)
" sys sysloc
" AC/ address (or -1 on bad index)
.sysloc:
lac u.ac
and o17777
jms betwen; d1; locn
@@ -154,7 +161,7 @@ swn:
dac u.ac
jmp sysexit
locsw: " table of system data structures for "sysloc" call
locsw: " table of system addresses for sysloc
lac .
iget; inode; userdata; sysdata; copy; copyz; betwen; dskrd
dskwr; dskbuf; dpdata; namei; pbsflgs; alloc; free; dspdata
@@ -162,34 +169,41 @@ locsw: " table of system data structures for "sysloc" call
locn:
.-locsw-1
" check if interrupt for user
" checks .int1 and .int2 (contain i-number of interrupt source)
" call:
" .insys/ 0
" jms chkint
" no: no interrupt, or intflg set (discards interupt)
" yes: PI off, .insys set
chkint: 0
lac .insys
sza
jmp chkint i
lac .int1
sna
jmp 1f
sad u.ofiles+2
jmp 2f
sza " in system?
jmp chkint i " yes: return
lac .int1 " get inumber of interrupt1 source?
sna " zero?
jmp 1f " yes: skip stdin check
sad u.ofiles+2 " non-zero: compare to stdin inumber
jmp 2f " same
1:
lac .int2
sna
jmp chkint i
sad u.ofiles+2
skp
jmp chkint i
dzm .int2
lac .int2 " get inum of interrupt 2 source?
sna " zero?
jmp chkint i " yes: return
sad u.ofiles+2 " non-zero: compare to stdin inumber
skp " match!
jmp chkint i " no match: return
dzm .int2 " clear int2 source
jmp 1f
2:
dzm .int1
dzm .int1 " clear int1 source
1:
"** 01-s1.pdf page 5
lac u.intflg
sza
jmp chkint i
lac u.intflg " get user intflg
sza " zero?
jmp chkint i " no: ignore
-1
dac .insys
ion
isz chkint
dac .insys " set "in system" flag
ion " enable interrupts
isz chkint " give skip return
jmp chkint i

View File

@@ -110,7 +110,7 @@
skp
jms error
lac d1
dac mode
dac mode " save mode bits for access
jms access
jms dslot
lac u.base
@@ -131,8 +131,8 @@
.unlink:
jms argname
dac u.base
lac d1
dac mode
lac d1 " mode bit 1 (write?)
dac mode " save for access call
jms access
dac d.i
jms dput
@@ -162,8 +162,8 @@
lac u.cdir
jms namei; 0:0
jms error
lac d1
dac mode
lac d1 " mode bit 1 (write?)
dac mode " save for access call
jms access
jms copy; 1:0; d.name; 4
jmp okexit
@@ -190,36 +190,39 @@
"** 01-s1.pdf page 10
jmp okexit
" open system call
" sys open; filename_ptr; flags (0 for read, 1 for write)
" returns w/ "fd" in AC (or -1 if not found)
.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
jms arg " get filename
dac 0f " save for namei
jms arg " get flags
sza " zero (read)
lac d1 " no: get write mode bit
sna " non-zero (write)?
lac d2 " no: get read mode bot
dac mode " save for access call
lac u.cdir " get current working directory
jms namei; 0:0 " search for file
jms error " error: return -1
jms iget " load inode
jms access " check access (may return w/ error to user)
lac i.flags " get file flags
and o20 " get directory bit
sna " is directory?
jmp open1 " no, join common code
lac mode " get access mode
and d1 " get write bit
sna " write access?
jmp open1 " no, continue
lac u.uid " yes: get uid?
sma " negative? (-1 is superuser)
jms error " no: return error
jmp open1 " yes: join common code
.creat:
lac d1
dac mode
lac d1 " mode bit 1 (write)
dac mode " save for access call
jms arg
dac .+2
jms copy; ..; name; 4
@@ -241,12 +244,12 @@
jmp open1
1:
jms access
lac u.ac
and o17
lac u.ac " get access bits from user AC (zero for lock!)
and o17 " mask to permissions
jms icreat
open1:
jms fassign
jms error
open1: " common exit for open/creat
jms fassign " assign fd slot
jms error " none free, return -1
jmp sysexit
"** 01-s1.pdf page 11
@@ -275,63 +278,67 @@ open1:
and d1
sza
jms error
lac i.flags
and o40
sna
jmp 1f
iof
lac ii
tad swr
lac i.flags " get inode flags
and o40 " get special file bit
sna " special?
jmp 1f " no
iof " yes: disable interrupts
lac ii " get i number
tad swr " get read routine table addr
dac .+1
jmp .. i
jmp .. i " dispatch to read routine
1:
lac u.base
dac 1f+1
lac u.count
dac 1f+2
lac f.badd
lac u.base " get user base
dac 1f+1 " save as iread base
lac u.count " get user count
dac 1f+2 " save as iread count
lac f.badd " get file offset
1:
jms iread; ..; ..
jmp exitrw
" write system call:
" AC/ fd
" sys write; buffer; count
" AC/ count or -1 on error
.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
jms arg " pick up buffer
and o17777 " mask to addr
dac u.base " save as I/O base
jms arg " pick up count
dac u.count " save as count
tad u.base " add base (get limit)
jms betwen; u.base; o17777 " check between base and end of memory
jms error " no: error
dac u.limit " yes: save as limit
jms finac " get fnode with fd from user AC
lac f.flags " get open file table flags
and d1 " open for write?
sna " yes, skip
jms error " no: error
lac i.flags " get inode flags
and o40 " get special bit?
"** 01-s1.pdf page 12
sna
jmp 1f
iof
lac ii
tad sww
sna " special?
jmp 1f " no
iof " special file (device node)
lac ii " get i number
tad sww " get write routine
dac .+1
jmp .. i
jmp .. i " dispatch to write routine
1: " here with regular file
lac u.base " get base
dac 1f+1 " save as iwrite arg 1
lac u.count " get count
dac 1f+2 " save as iwrite 2
lac f.badd " get fd offset
1:
lac u.base
dac 1f+1
lac u.count
dac 1f+2
lac f.badd
1:
jms iwrite; ..; ..
jms iwrite; ..; .. " write to file
exitrw:
dac u.ac
exitrw: " common exit for read/write system calls
dac u.ac " save return in user AC
tad f.badd
dac f.badd
jms iput
jms fput
jmp sysexit
dac f.badd " update file offset
jms iput " release inode
jms fput " release fnode
jmp sysexit " return to user

View File

@@ -1,15 +1,21 @@
"** 01-s1.pdf page 14
" s3
" search for user (process)
" call:
" jms searchu; worker_routine_addr
" worker called with copy of a process table entry in "lu"
" can return directly (from caller of searchu)
" index location 8 points to next process table entry
searchu: 0
lac searchu i
dac 9f+t+1
-mnproc
dac 9f+t
law ulist-1
dac 8
lac searchu i " fetch argument
dac 9f+t+1 " in t1
-mnproc " loop counter
dac 9f+t " in t0
law ulist-1 " ulist ptr
dac 8 " in index 8
1:
lac 8 i
lac 8 i " copy ulist entry to lu
dac lu
lac 8 i
dac lu+1
@@ -17,86 +23,96 @@ searchu: 0
dac lu+2
lac 8 i
dac lu+3
jms 9f+t+1 i
isz 9f+t
jmp 1b
isz searchu
jms 9f+t+1 i " call argument as subroutine
isz 9f+t " returned: loop done?
jmp 1b " no, do it again
isz searchu " skip argument
jmp searchu i
t = t+2
" look for a process with matching status
" jms lookfor; status
" found: ulist ptr in AC
" not found
lookfor: 0
jms searchu; 1f
isz lookfor
isz lookfor
isz lookfor " skip argument
isz lookfor " give skip return
jmp lookfor i
1: 0
1: 0 " worker called by searchu
lac lu
rtl; rtl; and o7
sad lookfor i
skp
jmp 1b i
rtl; rtl; and o7 " bits 0:2 of lu
sad lookfor i " match argument?
skp " yes
jmp 1b i " no, return, keep going
-3
tad 8
tad 8 " roll index 8 back to this entry
and o17777
isz lookfor
jmp lookfor i
isz lookfor " skip lookfor argument
jmp lookfor i " non-skip return
" fork system call:
" sys fork
" return at +1 in parent, child pid in AC
" return at +2 in child, parent pid in AC
.fork:
jms lookfor; 0 " not-used
jms lookfor; 0 " not-used " find an unused process slot
skp
jms error
dac 9f+t
isz uniqpid
jms error " none found- return error
dac 9f+t " save ulist ptr in t0
isz uniqpid " generate new pid
lac uniqpid
dac u.ac
dac u.ac " return in child pid in AC
law sysexit
dac u.swapret
lac o200000
dac u.swapret " return from system call when swapped back in
lac o200000 " change process status to out/ready (1->3)
tad u.ulistp i
dac u.ulistp i
jms dskswap; 07000
lac 9f+t
dac u.ulistp
lac o100000
jms dskswap; 07000 " swap parent out
lac 9f+t " get unused ulist slot back
dac u.ulistp " set ulist pointer
lac o100000 " mark child in/notready? (3->2)
xor u.ulistp i
dac u.ulistp i
lac u.pid
lac u.pid " get old (parent) pid
"** 01-s1.pdf page 15
dac u.ac
dac u.ac " return parent pid in AC
lac uniqpid
dac u.pid
isz 9f+t
dac 9f+t i
isz u.rq+8
dzm u.intflg
jmp sysexit
dac u.pid " set child pid
isz 9f+t " advance to second word in process table
dac 9f+t i " set pid in process table
isz u.rq+8 " give skip return
dzm u.intflg " clear int flag
jmp sysexit " return in child process
t= t+1
badcal:
clon
badcal: " bad (unimplemented) system call
clon " clear any pending clock interrupt?
-1
dac 7
.save:
lac d1
dac 7 " set location 7 to -1?!
" fall into "save" system call
" Ken says save files could be resumed, and used for checkpointing!
.save: " "sys save" system call
lac d1 " get inode 1 (core file?)
jms iget
cla
jms iwrite; 4096; 4096
jms iwrite; userdata; 64
jms iwrite; 4096; 4096 " dump core
jms iwrite; userdata; 64 " and user area
jms iput
.exit:
lac u.dspbuf
sna
jmp .+3
law dspbuf
jms movdsp
sna " process using display?
jmp .+3 " no
law dspbuf " yes
jms movdsp " move display
jms awake
lac u.ulistp i
and o77777
and o77777 " mark process table entry free
dac u.ulistp i
isz u.ulistp
dzm u.ulistp i
jms swap
dzm u.ulistp i " clear pid in process table
jms swap " find a new process to run
.rmes:
jms awake
@@ -124,25 +140,28 @@ badcal:
t = t+1
"** 01-s1.pdf page 16
" smes system call
" AC/ pid
" sys smes
.smes:
lac u.ac
sna spa
jms error
jms searchu; 1f
lac u.ac " get pid from user AC
sna spa " >0?
jms error " no: error
jms searchu; 1f " search for process
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
1: 0 " worker for searchu
lac lu+1 " get pid
sad u.ac " match?
skp " yes
jmp 1b i " no
lac lu+2 " get mailbox
sad dm1 " -1?
jmp 1f " yes
lac o100000 " no: increment process status
tad u.ulistp i
dac u.ulistp i
law 2
@@ -177,19 +196,19 @@ t = t+1
awake: 0
jms searchu; 1f
jmp awake i
1: 0
lac u.pid
sad lu+2
skp
jmp 1b i
1: 0 " searchu worker
lac u.pid " get caller pid
sad lu+2 " match process table entry?
skp " yes
jmp 1b i " no, return
-3
tad 8
dac 9f+t
tad 8 " get pointer to pid in process table??
dac 9f+t " save in t0
"** 01-s1.pdf page 17
lac o700000
lac o700000 " set high bits
tad 9f+t i
dac 9f+t i
jmp 1b i
jmp 1b i " return from worker
t = t+1
swr:
@@ -200,15 +219,16 @@ sww:
.halt: jms halt
" read routine for ttyin special file
rttyi:
jms chkint1
lac d1
jms getchar
jmp 1f
and o177
jms betwen; o101; o132
skp
tad o40
jms betwen; o101; o132 " upper case?
skp " no
tad o40 " yes: convert to lower
alss 9
jmp passone
1:
@@ -216,6 +236,7 @@ rttyi:
jms swap
jmp rttyi
" write routine for ttyout special file
wttyo:
jms chkint1
jms forall
@@ -243,6 +264,7 @@ wttyo:
jms swap
jmp wttyo
" read routine for (display) "keyboard" special file
rkbdi:
jms chkint1
lac d3
@@ -282,6 +304,7 @@ rkbdi:
jms swap
jmp rkbdi
" write routine for (graphic) "display" special file
wdspo:
jms chkint1
jms forall
@@ -292,6 +315,7 @@ wdspo:
jmp wdspo
" read routine for paper tape reader special file
rppti:
lac d4
jms getchar
@@ -307,6 +331,7 @@ rppti:
jmp rppti
"** 01-s1.pdf page 19
" write routine for paper tape punch special file
wppto:
jms forall
sna
@@ -331,6 +356,7 @@ wppto:
jms swap
jmp wppto
" common exit for special file
passone:
sad o4000
jmp okexit

View File

@@ -0,0 +1,371 @@
"** 01-s1.pdf page 21
" s4
" allocate a free disk block for a file (data or indirect)
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 a disk block
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
" load AC indirect (without using indirect!)
" AC/ address
" jms laci
" AC/ contents of address
laci: 0
and o17777 " clear everything but addr
tad o200000 " make into "lac addr"
dac .+1
lac .. " fetch
jmp laci i " return
"** 01-s1.pdf page 22
" skip if AC between two values (inclusive)
" jms betwen; low_ptr; high_ptr
" <not between>
" <between>
" listing has an alternate written in
" (which would require 'lac ptr' instead of 'ptr' args?)
betwen: 0
lmq cmq " get ~AC in MQ
lac betwen i " get low_ptr
dac 9f+t
isz betwen " skip low_ptr
lacq " get ~AC (-AC-1) from MQ
tad 9f+t i " get low-AC-1
sma " negative (AC >= low)?
jmp 1f " no, return w/o skip
lac betwen i " fetch high_ptr
dac 9f+t
isz betwen " skip high_ptr
lacq " get -AC-1
tad 9f+t i " add to high value (high-AC-1)
cma " complement (AC-high)
spa sna " AC-high <= 0?
1:
isz betwen " no: give happy (skip) return
lacq " restore ~AC
cma " restore AC
jmp betwen i " return w/o skip
" copy memory
" call:
" jms copy; src; dest; count
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
" copy zeroes (clear memory)
" call:
" jms copyz; pointer; count
copyz: 0
-1
tad copyz i " get call PC
dac 8 " save in index (pre-increments)
isz copyz " skip pointer
-1
tad copyz i " get count-1
cma " get negative count
dac 9f+t " save in t0
isz copyz " skip count
1:
dzm 8 i " zero word
isz 9f+t " done?
jmp 1b " no: loop
jmp copyz i " return
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
dac 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
dac 9f+t+2 "* lmq
-ndskbs
dac 9f+t
law dskbs "* -1 dac 8 written
dac 9f+t+1 "* lacq
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 d65 "** crossed out: d2-- 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 2f
1:
dzm 9f+t+1 i
law 1
tad 9f+t+1
dac .+2
jms copy; ..; dskbuf; 64
2:
jms collapse
jmp dskrd i
" write a file block (data, inode or indirect)
" AC/ block
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
" AC/ block
" jms dskio; dsld_bits
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
xor 9f+t+1
xor o200000
dac 9f+t
jms dsktrans; -64; dskbuf; 9f+t; dskio
isz dskio
jmp dskio i
t = t+1
" called with:
" jms dsktrans; -WC; MAC; addr_ptr?; dsld_ptr
dsktrans: 0
-10
dac 9f+t
1:
-1
tad dsktrans
dac 12
"** 01-s1.pdf page 26
dscs " clear status register
lac 12 i
dslw " load WC
lac 12 i
dslm " load MAC
lac 12 i
jms laci
dsld " load TA & SA
dzm .dskb
lac 12 i
jms laci
jms laci
dsls " load status
lac .dskb " check for interrupt
sna
jmp .-2
lac .dske " get status from interrupt
sma
jmp 12 i " return
isz 9f+t
jmp 1b
jms halt " 10 disk errors
t = t+1
halt: 0
isz 9f+t " spin for a while (process interrupts)
jmp .-1
iof " disable interrupts
hlt " halt
jms copy; law; 4096; 4096 " continued: copy system up to user memory?
hlt; jmp .-1 " halt for good
t = t+1

View File

@@ -1,75 +1,86 @@
"** 01-s1.pdf page 28
" s5
" read/write a process from/to swap space
" call:
" AC/ first word of process table
" jms dskswap; DSLD bits
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
cll; als 3 " get process disk address
dac 9f+t " save in t0
jms dsktrans; -64; userdata; 9f+t; dskswap " read/write user area
lac 9f+t " get swap addr back
tad o20 " advance by 16??
dac 9f+t " save
jms dsktrans; -4096; 4096; 9f+t; dskswap " read/write user memory
isz dskswap " skip bits
jmp dskswap i " return
t = t+1
access: 0
lac i.flags
lmq
lac u.uid
spa
jmp access i
sad i.uid
lrs 2
lacq
and mode
sza
jmp access i
jms error
lmq " save in MQ
lac u.uid " get user id
spa " negative?
jmp access i " yes: super user, return
sad i.uid " compare to file owner
lrs 2 " same: shift flags down two
lacq " get flags back
and mode " mode from system call
sza " access allowed?
jmp access i " yes: return
jms error " no: return error from system call
fassign: 0
-10
dac 9f+t
-10 " loop count
dac 9f+t " in t0
1:
lac 9f+t
tad d10
jms fget
lac 9f+t " get count
tad d10 " turn into fd
jms fget " fetch open file into "fnode"
jms halt " will not happen
lac f.flags
sma
jmp 1f
isz 9f+t
lac f.flags " get fnode flags
sma " sign bit set (active)?
jmp 1f " no: free
isz 9f+t " increment loop count & loop until zero
jmp 1b
jmp fassign i
1:
lac mode
xor o400000
dac f.flags
lac ii
dac f.i
lac mode " get mode from system call
xor o400000 " set sign bit
dac f.flags " save in fnode
lac ii " get i-number
dac f.i " save in fnode
lac 9f+t
tad d10
dac u.ac
dzm f.badd
jms fput
isz fassign
tad d10 " get fd
dac u.ac " return in user AC
dzm f.badd " clear file offset in fnode
jms fput " copy fnode back into u.ofiles
isz fassign " give skip return
jmp fassign i
t = t+1
" load fnode (open file entry) from u.ofiles
" AC/ user fd
" jms fget
" bad fd
" return with fnode set
fget: 0
jms betwen; d0; d9
jmp fget i
cll; mul; 3
jms betwen; d0; d9 " fd 0..9?
jmp fget i " no, return
cll; mul; 3 " multiply by three
lacq
"** 01-s1.pdf page 29
tad ofilesp
dac 9f+t
dac .+2
jms copy; ..; fnode; 3
isz fget
tad ofilesp " get pointer into u.ofiles
dac 9f+t " save in t0
dac .+2 " save as copy source
jms copy; ..; fnode; 3 " copy to "fnode"
isz fget " give skip return
jmp fget i
" copy fnode back to u.ofiles
" uses temp value set by "fget"
" (fget and fput calls must be paired)
fput: 0
lac 9f+t
dac .+3
@@ -138,6 +149,8 @@ dslot: 0
jmp 1b
jmp dslot i
" called with:
" AC/ mode
icreat: 0
dac 9f+t
jms dslot

View File

@@ -2,41 +2,41 @@
" s6
itrunc: 0
-7
dac 9f+t
lac idskpp
dac 9f+t+1
1:
lac 9f+t+1 i
sna
jmp 4f
-7 " loop 7 times
dac 9f+t " in t0
lac idskpp " pointer to inode block numbers
dac 9f+t+1 " save in t1
1: " top of loop for inode blocks
lac 9f+t+1 i " fetch next block number
sna " allocated?
jmp 4f " no
lac i.flags " check flags
and o200000
sna " large file?
jmp 3f " no
-64 " loop 64 times
dac 9f+t+2 " save count in t2
lac dskbufp " get pointer to dskbuf
dac 9f+t+3 " in t3
2: " inner loop for indirect blocks
lac 9f+t+1 i " get indirect block number
jms dskrd " read it
lac 9f+t+3 i " read block number from indirect
sza " free?
jms free " no: free it
isz 9f+t+3 " increment pointer into indirect block
isz 9f+t+2 " increment loop counter, skip if done
jmp 2b " not done: loop
3: " here with small file
lac 9f+t+1 i " load block number
jms free " free it
dzm 9f+t+1 i " clear block number
4: " bottom of loop for inode block ptrs
isz 9f+t+1 " increment block pointer
isz 9f+t " increment count, skip if done
jmp 1b " not done
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+2
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
and o577777 " clear large file flag
dac i.flags
jmp itrunc i
t = t+4
@@ -185,100 +185,107 @@ dput: 0
t = t+3
" allocate a block for a file, returns disk block number
" AC/ file offset
" jms pget
" AC/ disk block number
pget: 0
lrss 6
dac 9f+t
lrss 6 " convert offset to block
dac 9f+t " save as t0
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
sza " large file bit set?
jmp 2f " yes
lac 9f+t " no: small file
jms betwen; d0; d6 " block 0..6?
jmp 1f " no
tad idskpp " make into block number pointer
dac 9f+t " save in t0
lac 9f+t i " get disk block number
sna " allocated?
jms alloc " no: allocate now
dac 9f+t i " save (new) disk block number
jmp pget i " return disk block number
1: " here when file block>=7, not "large"
jms alloc " allocate indirect block
dac 9f+t+1 " save as t1
jms copy; i.dskps; dskbuf; 7 " copy all the disk block numbers
jms copyz; dskbuf+7; 64-7 " zero rest of indirect block
lac 9f+t+1 " get indirect block number back
jms dskwr " write indirect block to disk
lac 9f+t+1
jms dskwr
lac 9f+t+1
dac i.dskps
jms copyz; i.dskps+1; 6
dac i.dskps " save indirect as new first block
jms copyz; i.dskps+1; 6 " zero rest of block pointers
lac i.flags
xor o200000
xor o200000 " set "large file"
dac i.flags
2:
lac 9f+t
lrss 6
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
2: " here with "large file"
lac 9f+t " get file block number
lrss 6 " divide by 64 (indirects/block)
jms betwen; d0; d6 " ok now?
jms halt " file too big " no, you lose!
tad idskpp " yes: get indirect block pointer
dac 9f+t+1 " save in t1
lac 9f+t+1 i " get indirect block number
sna " allocated?
jms alloc " no, get it now
dac 9f+t+1 i " save (new) indirect block
dac 9f+t+2 " save as t2
jms dskrd " read indirect block
lac 9f+t " get original block number
and o77 " mod by 64
tad dskbufp " get pointer to disk block number
dac 9f+t+1 " save as t1
lac 9f+t+1 i " fetch disk block number
sza " allocated?
jmp pget i " yes: return
jms alloc " no: allocate data block
dac 9f+t " save as t0
lac 9f+t+2 " get indirect block number
jms dskrd " read it in
lac 9f+t " get data block number
dac 9f+t+1 i " save data block number
lac 9f+t+2
jms dskrd
lac 9f+t
dac 9f+t+1 i
lac 9f+t+2
jms dskwr
lac 9f+t
jmp pget i
jms dskwr " write indirect block back
lac 9f+t " get data block back
jmp pget i " return it
t = t+3
iwrite: 0
dac 9f+t
lac iwrite
dac 9f+t " save arg in t0
lac iwrite " load return address
"** 01-s1.pdf page 38
dac iread
lac cskp
dac iwrite
dac iread " save as iread return addr
lac cskp " load skip instruction
dac iwrite " save as iwrite instruction
jmp 1f
" iread from file referenced by loaded inode
" AC/ file offset
" jms iread; addr; count
iread: 0
dac 9f+t
lac cnop
dac iwrite
dac 9f+t " save offset in t0
lac cnop " get nop
dac iwrite " save as iwrite instruction
1:
-1
tad iread i
dac 10
tad iread i " get word before return addr
dac 10 " store in index 10 & 11
dac 11
isz iread
lac iread i
dac 9f+t+1
isz iread
isz iread " increment return addr
lac iread i " load addr
dac 9f+t+1 " save in t1
isz iread " increment return addr
lac o70000
xct iwrite
lac i.size
xct iwrite " skip if write
lac i.size " read: get file size
cma
tad 9f+t
tad 9f+t " add offset
cma
jms betwen; d0; 9f+t+1
lac 9f+t+1
@@ -332,6 +339,11 @@ cskp:
jmp 1b
t = t+4
" system call helper
" AC/ fd
" jms finac
" return with: fnode and inode loaded
" or makes error return to user
finac: 0
lac u.ac
jms fget
@@ -343,6 +355,7 @@ finac: 0
jms iget
jmp finac i
" update inode file size with value in AC
dacisize: 0
dac i.size
jms iput

View File

@@ -0,0 +1,372 @@
"** 01-s1.pdf page 41
" s7
pibreak: " priority interrupt break processing "chain"
dac .ac " save interrupt 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 " clock overflow (line frequency ticks)?
jmp 1f " no
lpb " load display push buttons
dac pbsflgs " save
isz s.tim+1 " increment low order tick count
skp " no overflow, skip second increment
isz s.tim " low order overflowed, increment high order count
isz uquant " increment user quantum counter
"** written: ttydelay -> ttyd1
"** written: ttyrestart -> ttyres1
" referenced in iread:
cnop:
nop
-1
dac 7 " set location 7 to -1
clon " enable clock interrupts, reset flag
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
dpcf
jmp piret
sma
jmp 1f
lda
dac .lpba
rlpd
jmp piret
1: ksf " (TTY) keyboard flag set?
jmp 1f " no
lac ttydelay
sma
isz ttydelay
krb " read keyboard buffer
dac char " save in char
sad o375 " interrupt char ('}'?)
jmp intrp1 " yes
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
"** BEGIN CROSSED OUT
1: sck " Graphic-2 keyboard flag set?
jmp 1f " no.
cck " yes: clear flag
lck " read character
dac char
sad o33 " code 33 (ESCAPE?)
jmp intrp2 " yes: mark interrupt
lac d3
jms putchar
nop
lac sfiles+2
jms wakeup
dac sfiles+2
jmp piret
1: rsf " paper tape ready?
jmp 1f " no
"** 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 " paper tape ready?
jmp 1f " no
pcf " clear ptp flag
lac d5
jms getchar " get next char
jmp .+3
psa
jmp piret
lac sfiles+4
jms wakeup
dac sfiles+4
jmp piret
"** BEGIN CROSSED OUT
1: spb " graphic 2 push button flag set?
jmp 1f " no
cpb " clear push button flag
lpb " load push button value
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 " card reader flag set?
jmp 1f " no
crrb
dac crchar
-1
dac crread
jmp piret
1: crrb " read card reader buffer??
piret: " return from priority interrupt
lac 0 " get LINK/PC
ral " restore LINK
lac .ac " restore AC
ion " reenable interrupts
jmp 0 i " return from interrupt
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: " here with keyboard interrupt
lac d6 " get keyboard special device number
dac .int1 " save as interrupt source
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

View File

@@ -8,14 +8,15 @@ dspbsz = 270
ndskbs = 4
" flags
.insys: 0
.int1: 0
.int2: 0
.ac: 0
.savblk: 0
.dsptm: 0
.dskb: 0
.dske: 0
" interupt flags
.insys: 0 " "in system"
.int1: 0 " inode for interrupt 1
.int2: 0 " inode for interrupt 2
.ac: 0 " saved AC from interrupt
.savblk: 0 " set by system call, cleared by disk i/o
.dsptm: 0 " display restart countdown (10 ticks)
.dskb: 0 " set on disk interrupt
.dske: 0 " status from disk interrupt
" pointers
tadu: tad ulist
@@ -110,25 +111,25 @@ dspbuf:
.=.+30
coldentry:
dzm 0100 " not re-entrant
caf
ion
clon
law 3072
caf " clear all flags
ion " enable interrupts
clon " clear clock flag
law 3072 " initialize display....
wcga
jms dspinit
law dspbuf
jms movdsp
cla
cla " read system block from disk
jms dskio; 06000
jms copy; dskbuf; sysdata; ulist-sysdata
lac d3
jms copy; dskbuf; sysdata; ulist-sysdata " copy to system data
lac d3 " look for "init" in default directory
jms namei; initf
jms halt
"** 01-s1.pdf page 50
jms iget
cla
jms iread; 4096; 4096
jmp 4096
jms iread; 4096; 4096 " read in "init"
jmp 4096 " start process 1
. = dspbuf+dspbsz+3
dskbuf = 07700
dskbs: .=.+65+65+65+65
@@ -144,9 +145,9 @@ name: .=.+4
lnkaddr: .=.+1
char: .=.+1
dskaddr: .=.+1
uniqpid: 1
lu: .=.+4
sfiles: .=.+10
uniqpid: 1 " pid generator
lu: .=.+4 " user (process) table entry copy
sfiles: .=.+10 " wait addresses for special files
dpdata:
dpstat: .=.+1
dpread: .=.+1
@@ -158,12 +159,24 @@ dspdata:
crdata:
crread: .=.+1
crchar: .=.+1
sysdata:
s.nxfblk: .=.+1
s.nfblks: .=.+1
s.fblks: .=.+10
s.uniq: .=.+1
s.tim: .=.+2
sysdata: " system data 64 words saved to disk
s.nxfblk: .=.+1 " pointer to next free block??
s.nfblks: .=.+1 " number of free blocks (in fblks?)
s.fblks: .=.+10 " cached free block numbers
s.uniq: .=.+1 " next unique value
s.tim: .=.+2 " (up?)time in 60Hz ticks (low, high)
" process table
" first word
" bits 0:2 -- status
" 0: free slot
" 1: in/ready
" 2: in/notready
" 3: out/ready
" 4: out/notready??
" bits 3:17 -- disk swap address/8
" second word: process pid
" third word: used for smes/rmes
" fourth word: ??
ulist:
0131000;1;0;0
0031040;0;0;0
@@ -175,40 +188,51 @@ ulist:
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
userdata: " "ustruct" (swappable)
u.ac: 0 " user AC
u.mq: 0 " user MQ
u.rq: .=.+9 " user 010-017, user PC
u.uid: -1 " user id
u.pid: 1 " process id
u.cdir: 3 " connected directory (inode number?)
u.ulistp: ulist " pointer to process table entry
u.swapret: 0 " kernel routine to resume at after swap in
u.base: 0 " start of user buffer
u.count: 0 " size of user buffer
"** 01-s1.pdf page 51
u.limit: 0
u.ofiles: .=.+30
u.limit: 0 " end of user buffer
u.ofiles: .=.+30 " open files (10 "fnode" entries)
u.dspbuf: 0
u.intflg: 1
.=userdata+64
ii: .=.+1
inode:
i.flags: .=.+1
i.dskps: .=.+7
i.uid: .=.+1
i.nlks: .=.+1
ii: .=.+1 " number of i-node in inode:
inode: " disk inode in memory:
i.flags: .=.+1 " inode flags
" 400000 free?? (checked/toggled by icreat)
" 200000 large file
" 000040 special device (indicated by inum)?
" 000020 directory
" 000010 owner read
" 000004 owner write
" 000002 world read
" 000001 world write
i.dskps: .=.+7 " disk block pointers (indirect if "large file")
i.uid: .=.+1 " owner
i.nlks: .=.+1 " link count
i.size: .=.+1
i.uniq: .=.+1
i.uniq: .=.+1 " unique number
.= inode+12
di: .=.+1
dnode:
d.i: .=.+1
d.name: .=.+4
d.uniq: .=.+1
dnode: " directory entry:
d.i: .=.+1 " inode number
d.name: .=.+4 " name (space padded)
d.uniq: .=.+1 " unique number from directory inode
. = dnode+8
fnode:
f.flags: .=.+1
f.badd: .=.+1
f.i: 0
fnode: " open file entry
f.flags: .=.+1 " see below
f.badd: .=.+1 " offset
f.i: 0 " file i-number
" f.flags:
" 400000 in use
" 000002 read
" 000001 write