mirror of
https://github.com/DoctorWkt/pdp7-unix.git
synced 2026-02-06 00:25:10 +00:00
Merge branch 'master' of https://github.com/DoctorWkt/pdp7-unix
This commit is contained in:
@@ -125,7 +125,7 @@ init2: 0 " start pass 2
|
||||
lac d1
|
||||
"** 05-1-4.pdf page 34
|
||||
dac passno " passno = 1
|
||||
sys write; 1f; 2f-1f " output II
|
||||
sys write; 1f; 2f-1f " output II\n
|
||||
jms init
|
||||
lac o17
|
||||
sys creat; 2f " create a.out
|
||||
@@ -479,9 +479,9 @@ nf1:
|
||||
sys open; fname: 0; 0 " open fname
|
||||
dac iof " save fd
|
||||
sma " open ok?
|
||||
lac passno " yes, load pass number
|
||||
sna " open failed: skip or open ok, pass 2
|
||||
jmp nextfil i " pass 1, open OK, return.
|
||||
lac passno " yes: load pass number
|
||||
sna " no: open failed: skip or open ok, pass 2
|
||||
jmp nextfil i " pass 1, open OK, return.
|
||||
lac fname " load filename pointer
|
||||
dac 1f " save for write
|
||||
lac d1 " stdout
|
||||
|
||||
123
src/cmd/ops.s
Normal file
123
src/cmd/ops.s
Normal file
@@ -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)
|
||||
63
src/sys/s3.s
63
src/sys/s3.s
@@ -1,7 +1,7 @@
|
||||
"** 01-s1.pdf page 14
|
||||
" s3
|
||||
|
||||
" search for user (process)
|
||||
" search for user (process) table entry
|
||||
" call:
|
||||
" jms searchu; worker_routine_addr
|
||||
" worker called with copy of a process table entry in "lu"
|
||||
@@ -113,36 +113,44 @@ badcal: " bad (unimplemented) system call
|
||||
isz u.ulistp
|
||||
dzm u.ulistp i " clear pid in process table
|
||||
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:
|
||||
jms awake
|
||||
lac o100000
|
||||
lac o100000 " mark this process to "not ready"
|
||||
tad u.ulistp i
|
||||
dac u.ulistp i
|
||||
law 2
|
||||
tad u.ulistp
|
||||
dac 9f+t
|
||||
dac 9f+t " pointer to msg status in proc table
|
||||
-1
|
||||
dac 9f+t i
|
||||
jms swap
|
||||
dac 9f+t i " set to -1 (waiting for message)
|
||||
jms swap " switch processes
|
||||
law 2
|
||||
tad u.ulistp
|
||||
dac 9f+t
|
||||
lac 9f+t i
|
||||
cma
|
||||
dac u.ac
|
||||
dzm 9f+t i
|
||||
lac 9f+t i " get msg status word
|
||||
cma " complement (get sender pid)
|
||||
dac u.ac " return in user AC
|
||||
dzm 9f+t i " clear status word
|
||||
isz 9f+t
|
||||
lac 9f+t i
|
||||
dac u.mq
|
||||
dzm 9f+t i
|
||||
lac 9f+t i " get message
|
||||
dac u.mq " return in user MQ
|
||||
dzm 9f+t i " clear message
|
||||
jmp sysexit
|
||||
t = t+1
|
||||
|
||||
"** 01-s1.pdf page 16
|
||||
" smes system call
|
||||
" AC/ pid
|
||||
" MQ/ message
|
||||
" sys smes
|
||||
" returns with message delivered, or error if process does not exit
|
||||
.smes:
|
||||
lac u.ac " get pid from user AC
|
||||
sna spa " >0?
|
||||
@@ -158,10 +166,10 @@ t = t+1
|
||||
sad u.ac " match?
|
||||
skp " yes
|
||||
jmp 1b i " no
|
||||
lac lu+2 " get mailbox
|
||||
lac lu+2 " get mailbox status
|
||||
sad dm1 " -1?
|
||||
jmp 1f " yes
|
||||
lac o100000 " no: increment process status
|
||||
lac o100000 " no: bump our process status (to notready?)
|
||||
tad u.ulistp i
|
||||
dac u.ulistp i
|
||||
law 2
|
||||
@@ -178,35 +186,36 @@ t = t+1
|
||||
1:
|
||||
-3
|
||||
tad 8
|
||||
dac 9f+t
|
||||
lac o700000
|
||||
dac 9f+t " pointer to dest process ulist entry
|
||||
lac o700000 " complement process status? marks ready??
|
||||
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
|
||||
isz 9f+t " point to mailbox word?
|
||||
lac u.pid " get our pid
|
||||
cma " complement
|
||||
dac 9f+t i " store in mailbox??
|
||||
isz 9f+t " advance to next word
|
||||
lac u.mq " get user MQ
|
||||
dac 9f+t i " save as message
|
||||
jmp okexit
|
||||
t = t+1
|
||||
|
||||
" wake up process hanging on rmes for current process??
|
||||
awake: 0
|
||||
jms searchu; 1f
|
||||
jmp awake i
|
||||
1: 0 " searchu worker
|
||||
lac u.pid " get caller pid
|
||||
sad lu+2 " match process table entry?
|
||||
sad lu+2 " match mailbox status?
|
||||
skp " yes
|
||||
jmp 1b i " no, return
|
||||
-3
|
||||
tad 8 " get pointer to pid in process table??
|
||||
tad 8 " get pointer to process table entry
|
||||
dac 9f+t " save in t0
|
||||
"** 01-s1.pdf page 17
|
||||
lac o700000 " set high bits
|
||||
tad 9f+t i
|
||||
lac o700000
|
||||
tad 9f+t i " complement process status (mark ready)??
|
||||
dac 9f+t i
|
||||
jmp 1b i " return from worker
|
||||
t = t+1
|
||||
|
||||
@@ -330,7 +330,7 @@ putcr: 0
|
||||
cla
|
||||
jmp putcr i
|
||||
|
||||
intrp1: " here with keyboard interrupt
|
||||
intrp1: " here with TTY interrupt character
|
||||
lac d6 " get keyboard special device number
|
||||
dac .int1 " save as interrupt source
|
||||
lac d1
|
||||
|
||||
Reference in New Issue
Block a user