Merge branch 'master' of https://github.com/DoctorWkt/pdp7-unix
This commit is contained in:
+3
-3
@@ -125,7 +125,7 @@ init2: 0 " start pass 2
|
|||||||
lac d1
|
lac d1
|
||||||
"** 05-1-4.pdf page 34
|
"** 05-1-4.pdf page 34
|
||||||
dac passno " passno = 1
|
dac passno " passno = 1
|
||||||
sys write; 1f; 2f-1f " output II
|
sys write; 1f; 2f-1f " output II\n
|
||||||
jms init
|
jms init
|
||||||
lac o17
|
lac o17
|
||||||
sys creat; 2f " create a.out
|
sys creat; 2f " create a.out
|
||||||
@@ -479,8 +479,8 @@ nf1:
|
|||||||
sys open; fname: 0; 0 " open fname
|
sys open; fname: 0; 0 " open fname
|
||||||
dac iof " save fd
|
dac iof " save fd
|
||||||
sma " open ok?
|
sma " open ok?
|
||||||
lac passno " yes, load pass number
|
lac passno " yes: load pass number
|
||||||
sna " open failed: skip or open ok, pass 2
|
sna " no: open failed: skip or open ok, pass 2
|
||||||
jmp nextfil i " pass 1, open OK, return.
|
jmp nextfil i " pass 1, open OK, return.
|
||||||
lac fname " load filename pointer
|
lac fname " load filename pointer
|
||||||
dac 1f " save for write
|
dac 1f " save for write
|
||||||
|
|||||||
+123
@@ -0,0 +1,123 @@
|
|||||||
|
" ops and system calls from as7; as.s has no initial symbol table
|
||||||
|
" so this needs to be included in any assembly of user programs
|
||||||
|
|
||||||
|
" "sys" has it's own sop.s which includes I/O instructions, but lacks
|
||||||
|
" system call definitions, and lacks some instructions used in
|
||||||
|
" commands but not in the kernel, so it can't have been the file used
|
||||||
|
" for user assemblies.
|
||||||
|
|
||||||
|
save = 1 " saves core dump & user area!
|
||||||
|
getuid = 2
|
||||||
|
open = 3
|
||||||
|
read = 4
|
||||||
|
write = 5
|
||||||
|
creat = 6
|
||||||
|
seek = 7
|
||||||
|
tell = 8
|
||||||
|
close = 9
|
||||||
|
link = 10
|
||||||
|
unlink = 11
|
||||||
|
setuid = 12
|
||||||
|
rename = 13
|
||||||
|
exit = 14
|
||||||
|
time = 15
|
||||||
|
intrp = 16
|
||||||
|
chdir = 17
|
||||||
|
chmod = 18
|
||||||
|
chown = 19
|
||||||
|
" 20 removed
|
||||||
|
sysloc = 21 " return system addresses
|
||||||
|
" 22 removed
|
||||||
|
capt = 23 " capture display?
|
||||||
|
rele = 24 " release display?
|
||||||
|
status = 25 " "stat"
|
||||||
|
smes = 27
|
||||||
|
rmes = 28
|
||||||
|
fork = 29
|
||||||
|
|
||||||
|
" List of instruction names and machine code values
|
||||||
|
" These come from https://raw.githubusercontent.com/simh/
|
||||||
|
|
||||||
|
sys = 0020000 " "cal i" instruction (trap indirect thru 020)
|
||||||
|
i = 0020000 " indirect bit
|
||||||
|
|
||||||
|
" memory reference instructions
|
||||||
|
dac = 0040000 " deposit AC
|
||||||
|
jms = 0100000 " jump to subroutine
|
||||||
|
dzm = 0140000 " deposit zero in memory
|
||||||
|
lac = 0200000 " load AC
|
||||||
|
xor = 0240000 " exclusive or
|
||||||
|
add = 0300000 " one's complement add
|
||||||
|
tad = 0340000 " two's complement add
|
||||||
|
xct = 0400000 " execute
|
||||||
|
isz = 0440000 " increment and skip if zero
|
||||||
|
and = 0500000 " AND with contents of Y
|
||||||
|
sad = 0540000 " skip if AC different from content of Y
|
||||||
|
jmp = 0600000 " jump to Y
|
||||||
|
|
||||||
|
" Type 177 Extended Arithmetic Element (EAE)
|
||||||
|
eae = 0640000 " base instruction (nop)
|
||||||
|
osc = 0640001 " OR SC into AC
|
||||||
|
omq = 0640002 " OR MQ into AC
|
||||||
|
cmq = 0640004 " Complement MQ
|
||||||
|
div = 0640323 " divide
|
||||||
|
norm = 0640444 " normalize unsigned
|
||||||
|
lls = 0640600 " long left shift
|
||||||
|
als = 0640700 " AC shift
|
||||||
|
lrs = 0640500 " long right shift
|
||||||
|
lacs = 0641001 " load AC with SC
|
||||||
|
lacq = 0641002 " load AC with MQ
|
||||||
|
abs = 0644000 " absolute value
|
||||||
|
divs = 0644323 " divide signed
|
||||||
|
|
||||||
|
clq = 0650000 " clear MQ
|
||||||
|
frdiv = 0650323 " fractional divide
|
||||||
|
lmq = 0652000 " load MQ from AC
|
||||||
|
mul = 0653122 " multiply
|
||||||
|
idiv = 0653323 " integer divide
|
||||||
|
idivs = 0657323 " integer divide signed
|
||||||
|
frdivs = 0654323 " fractional divide signed
|
||||||
|
muls = 0657122 " multiply signed
|
||||||
|
|
||||||
|
norms = 0660444 " normalize signed
|
||||||
|
gsm = 0664000 " get sign and magnitude
|
||||||
|
lrss = 0660500 " long right shift signed
|
||||||
|
llss = 0660600 " long left shift signed
|
||||||
|
alss = 0660700 " AC left shift signed
|
||||||
|
|
||||||
|
" Operate Instructions
|
||||||
|
|
||||||
|
" Group 1 (OPR 1) instructions
|
||||||
|
opr = 0740000 " base operate instruction (nop)
|
||||||
|
nop = 0740000
|
||||||
|
cma = 0740001 " complement accumulator
|
||||||
|
cml = 0740002 " complement link
|
||||||
|
oas = 0740004 " inclusive or accumulator switches
|
||||||
|
ral = 0740010 " rotate (ac link) left
|
||||||
|
rar = 0740020 " rotate (ac link) right
|
||||||
|
hlt = 0740040 " HALT
|
||||||
|
xx = 0740040
|
||||||
|
sma = 0740100 " skip on minus accumulator
|
||||||
|
sza = 0740200 " skip on zero accumulator
|
||||||
|
snl = 0740400 " skip on non-zero link
|
||||||
|
|
||||||
|
skp = 0741000 " unconditional skip
|
||||||
|
spa = 0741100 " skip on positive accumulator
|
||||||
|
sna = 0741200 " skip on negative accumulator
|
||||||
|
szl = 0741400 " skip on zero link
|
||||||
|
|
||||||
|
rtl = 0742010 " rotate two left (ral*2)
|
||||||
|
rtr = 0742020 " rotate two right (rar*2)
|
||||||
|
|
||||||
|
cll = 0744000 " clear link
|
||||||
|
stl = 0744002 " set link
|
||||||
|
rcl = 0744010 " clear link rotate left
|
||||||
|
rcr = 0744020 " clear link rotate right
|
||||||
|
|
||||||
|
cla = 0750000 " clear accumulator
|
||||||
|
clc = 0750001 " clear and complement acc
|
||||||
|
las = 0750004 " load acc from switches
|
||||||
|
glk = 0750010 " get link
|
||||||
|
|
||||||
|
" Group 2 operate
|
||||||
|
law = 0760000 " load accumulator with (instruction)
|
||||||
+36
-27
@@ -1,7 +1,7 @@
|
|||||||
"** 01-s1.pdf page 14
|
"** 01-s1.pdf page 14
|
||||||
" s3
|
" s3
|
||||||
|
|
||||||
" search for user (process)
|
" search for user (process) table entry
|
||||||
" call:
|
" call:
|
||||||
" jms searchu; worker_routine_addr
|
" jms searchu; worker_routine_addr
|
||||||
" worker called with copy of a process table entry in "lu"
|
" worker called with copy of a process table entry in "lu"
|
||||||
@@ -113,36 +113,44 @@ badcal: " bad (unimplemented) system call
|
|||||||
isz u.ulistp
|
isz u.ulistp
|
||||||
dzm u.ulistp i " clear pid in process table
|
dzm u.ulistp i " clear pid in process table
|
||||||
jms swap " find a new process to run
|
jms swap " find a new process to run
|
||||||
|
" exit falls into "rmes" !!!
|
||||||
|
|
||||||
|
" rmes system call
|
||||||
|
" sys smes
|
||||||
|
" returns with message delivered, or error if process does not exit
|
||||||
|
" AC/ sending pid
|
||||||
|
" MQ/ message
|
||||||
.rmes:
|
.rmes:
|
||||||
jms awake
|
jms awake
|
||||||
lac o100000
|
lac o100000 " mark this process to "not ready"
|
||||||
tad u.ulistp i
|
tad u.ulistp i
|
||||||
dac u.ulistp i
|
dac u.ulistp i
|
||||||
law 2
|
law 2
|
||||||
tad u.ulistp
|
tad u.ulistp
|
||||||
dac 9f+t
|
dac 9f+t " pointer to msg status in proc table
|
||||||
-1
|
-1
|
||||||
dac 9f+t i
|
dac 9f+t i " set to -1 (waiting for message)
|
||||||
jms swap
|
jms swap " switch processes
|
||||||
law 2
|
law 2
|
||||||
tad u.ulistp
|
tad u.ulistp
|
||||||
dac 9f+t
|
dac 9f+t
|
||||||
lac 9f+t i
|
lac 9f+t i " get msg status word
|
||||||
cma
|
cma " complement (get sender pid)
|
||||||
dac u.ac
|
dac u.ac " return in user AC
|
||||||
dzm 9f+t i
|
dzm 9f+t i " clear status word
|
||||||
isz 9f+t
|
isz 9f+t
|
||||||
lac 9f+t i
|
lac 9f+t i " get message
|
||||||
dac u.mq
|
dac u.mq " return in user MQ
|
||||||
dzm 9f+t i
|
dzm 9f+t i " clear message
|
||||||
jmp sysexit
|
jmp sysexit
|
||||||
t = t+1
|
t = t+1
|
||||||
|
|
||||||
"** 01-s1.pdf page 16
|
"** 01-s1.pdf page 16
|
||||||
" smes system call
|
" smes system call
|
||||||
" AC/ pid
|
" AC/ pid
|
||||||
|
" MQ/ message
|
||||||
" sys smes
|
" sys smes
|
||||||
|
" returns with message delivered, or error if process does not exit
|
||||||
.smes:
|
.smes:
|
||||||
lac u.ac " get pid from user AC
|
lac u.ac " get pid from user AC
|
||||||
sna spa " >0?
|
sna spa " >0?
|
||||||
@@ -158,10 +166,10 @@ t = t+1
|
|||||||
sad u.ac " match?
|
sad u.ac " match?
|
||||||
skp " yes
|
skp " yes
|
||||||
jmp 1b i " no
|
jmp 1b i " no
|
||||||
lac lu+2 " get mailbox
|
lac lu+2 " get mailbox status
|
||||||
sad dm1 " -1?
|
sad dm1 " -1?
|
||||||
jmp 1f " yes
|
jmp 1f " yes
|
||||||
lac o100000 " no: increment process status
|
lac o100000 " no: bump our process status (to notready?)
|
||||||
tad u.ulistp i
|
tad u.ulistp i
|
||||||
dac u.ulistp i
|
dac u.ulistp i
|
||||||
law 2
|
law 2
|
||||||
@@ -178,35 +186,36 @@ t = t+1
|
|||||||
1:
|
1:
|
||||||
-3
|
-3
|
||||||
tad 8
|
tad 8
|
||||||
dac 9f+t
|
dac 9f+t " pointer to dest process ulist entry
|
||||||
lac o700000
|
lac o700000 " complement process status? marks ready??
|
||||||
tad 9f+t i
|
tad 9f+t i
|
||||||
dac 9f+t i
|
dac 9f+t i
|
||||||
isz 9f+t
|
isz 9f+t
|
||||||
isz 9f+t
|
isz 9f+t " point to mailbox word?
|
||||||
lac u.pid
|
lac u.pid " get our pid
|
||||||
cma
|
cma " complement
|
||||||
dac 9f+t i
|
dac 9f+t i " store in mailbox??
|
||||||
isz 9f+t
|
isz 9f+t " advance to next word
|
||||||
lac u.mq
|
lac u.mq " get user MQ
|
||||||
dac 9f+t i
|
dac 9f+t i " save as message
|
||||||
jmp okexit
|
jmp okexit
|
||||||
t = t+1
|
t = t+1
|
||||||
|
|
||||||
|
" wake up process hanging on rmes for current process??
|
||||||
awake: 0
|
awake: 0
|
||||||
jms searchu; 1f
|
jms searchu; 1f
|
||||||
jmp awake i
|
jmp awake i
|
||||||
1: 0 " searchu worker
|
1: 0 " searchu worker
|
||||||
lac u.pid " get caller pid
|
lac u.pid " get caller pid
|
||||||
sad lu+2 " match process table entry?
|
sad lu+2 " match mailbox status?
|
||||||
skp " yes
|
skp " yes
|
||||||
jmp 1b i " no, return
|
jmp 1b i " no, return
|
||||||
-3
|
-3
|
||||||
tad 8 " get pointer to pid in process table??
|
tad 8 " get pointer to process table entry
|
||||||
dac 9f+t " save in t0
|
dac 9f+t " save in t0
|
||||||
"** 01-s1.pdf page 17
|
"** 01-s1.pdf page 17
|
||||||
lac o700000 " set high bits
|
lac o700000
|
||||||
tad 9f+t i
|
tad 9f+t i " complement process status (mark ready)??
|
||||||
dac 9f+t i
|
dac 9f+t i
|
||||||
jmp 1b i " return from worker
|
jmp 1b i " return from worker
|
||||||
t = t+1
|
t = t+1
|
||||||
|
|||||||
+1
-1
@@ -330,7 +330,7 @@ putcr: 0
|
|||||||
cla
|
cla
|
||||||
jmp putcr i
|
jmp putcr i
|
||||||
|
|
||||||
intrp1: " here with keyboard interrupt
|
intrp1: " here with TTY interrupt character
|
||||||
lac d6 " get keyboard special device number
|
lac d6 " get keyboard special device number
|
||||||
dac .int1 " save as interrupt source
|
dac .int1 " save as interrupt source
|
||||||
lac d1
|
lac d1
|
||||||
|
|||||||
Reference in New Issue
Block a user