Add comments to "dmabs.s"

This commit is contained in:
Phil Budne
2016-03-24 13:39:47 -04:00
parent 853318f48d
commit e51acda631
+121 -107
View File
@@ -1,49 +1,63 @@
" dmabs " dmabs
" takes a list of files on command line and punches out each
" to paper tape with a "hardware read-in" (HRI) bootstrap
" program in front of them.
" Bob Supnik says:
" The PDP-7/9/15 hardware read-in used a simple format where
" the start address was specified in the address switches, and
" then 18b words were deposited sequentially in memory. Binary
" format was distinguished by having the high order bit (0200)
" in each 8b tape frame set, so that leader (all 0s) could be
" ignored. A frame with bit 1 set (0100) indicated end of
" load; the last word was supposed to be either a JMP (to
" start the program running) or a HLT.
lac o17 lac o17
sys creat; punout sys creat; punout " open paper tape punch
spa spa
sys save sys save " open failed: dump core
dac fo dac fo
lac 017777 lac 017777
tad d1 tad d1
dac name dac name " get pointer to argv[0]
jms space jms space " punch 10 inch leader
100 100
loop: loop: " loop for input files
dzm oldsum dzm oldsum " clear checksum
lac initcmd lac initcmd
dac comand dac comand " reset command to "dac"
lac i 017777 lac i 017777 " get arg count
sad d4 sad d4 " anything left?
jmp stop jmp stop " no: stop
tad dm4 tad dm4 " decrement argc by 4
dac i 017777 dac i 017777
lac name lac name " advance arg pointer
tad d4 tad d4
dac name dac name
dump1: dump1: " (label not used)
lac comand lac comand " get command word
xor dactra xor dactra " transmute dac to jmp
dac tracmd dac tracmd
dump2: dump2: " (label not used)
sys open; name: 0; 0 sys open; name: 0; 0 " open file
spa spa
jmp opnerr jmp opnerr " open failed
dac fi dac fi " save input fd
-bootsiz -bootsiz " get length of bootstrap
dac c1 dac c1
law boot-1 law boot-1 " get pointer to boostrap in i8
dac 8 dac 8
1: 1:
lac i 8 lac i 8 " fetch word from bootstrap
jms put jms put " write to tape
isz c1 isz c1 " done?
jmp 1b jmp 1b " no: loop
lac bootcmd lac bootcmd " write "jmp" instruction to tape
lrs 12 lrs 12
jms put1 jms put1
lac bootcmd lac bootcmd
@@ -51,108 +65,108 @@ dump2:
jms put1 jms put1
lac bootcmd lac bootcmd
and o77 and o77
xor o300 xor o300 " final frame of jmp word: 0100 set
jms put2 jms put2
jms space jms space " punch three empty frames
3 3
dump3: dump3: " block loop
-1 -1 " reset i8 to buffer
tad bufp tad bufp
dac 8 dac 8
-64 -64 " get count
dac c1 dac c1
1: 1:
dzm i 8 dzm i 8 " loop zeroing buffer
isz c1 isz c1
jmp 1b jmp 1b
lac fi lac fi
sys read; bufp: buf; 64 sys read; bufp: buf; 64 " read block from input file
sna sna " got some?
jmp done jmp done " done
dac count dac count " save count
-1 -1
tad bufp tad bufp
dac 8 dac 8 " point i8 to input buffer
-64 -64
dac c1 dac c1 " reset count
cla cla
1: 1: " loop for 1's complement sum of buffer
add i 8 add i 8
isz c1 isz c1
jmp 1b jmp 1b
sna sna " sum non-zero?
jmp dump4 jmp dump4 " no: is zero: skip this block
dac newsum dac newsum " save as new sum
lac comand lac comand " get command word
jms put jms put " write to tape
lac count lac count " get positive count
jms put jms put " write to tape
lac oldsum lac oldsum
add comand add comand
add count add count
jms put jms put " write oldsum+command+count
lac newsum lac newsum " copy new sum to old sum
dac oldsum dac oldsum
jms space jms space " write three empty frame
3 3
-1 -1 " reset i8 to input buffer
tad bufp tad bufp
dac 8 dac 8
-1 -1
tad count tad count
cma cma
dac c1 dac c1 " reset counter
1: 1: " loop writing block to tape
lac i 8 lac i 8
jms put jms put
isz c1 isz c1
jmp 1b jmp 1b
jms space jms space " follow with 1 inch trailer
10 10
dump4: dump4: " end of block
lac comand lac comand " advance command word by count
tad count tad count
dac comand dac comand
jmp dump3 jmp dump3 " loop for another block
done: done: " here at end of input file
lac tracmd lac tracmd " get transfer command (jmp)
jms put " write to tape
cla " write a zero word
jms put jms put
cla lac oldsum " get checksum
jms put add tracmd " add in jmp command word
lac oldsum jms put " write to tape
add tracmd jms space " write two inch trailer
jms put
jms space
20 20
lac fi lac fi " close input file
sys close sys close
jmp loop jmp loop " loop for another input file
stop: stop:
cla cla
jms put jms put " write a zero binary word to tape
jms space jms space " write 10 inch trailer
100 100
sys exit sys exit
space: 0 space: 0 " punch empty frames (count after jms)
-1 -1
tad i space tad i space
cma cma
dac c1 dac c1 " store negative count
isz space isz space " skip count word
1: 1:
lac o400 lac o400 " defeat NUL removal
jms put2 jms put2 " write one empty frame
isz c1 isz c1 " done?
jmp 1b jmp 1b " no
jmp i space jmp i space
put: 0 put: 0 " write a (binary) word (as three frames)
dac 1f dac 1f
lrs 12 lrs 12
jms put1 jms put1
@@ -164,13 +178,13 @@ put: 0
jmp i put jmp i put
1:0 1:0
put1:0 put1:0 " write one frame of a binary word
and o77 and o77
xor o200 xor o200 " light the high bit
jms put2 jms put2
jmp i put1 jmp i put1
put2: 0 put2: 0 " write one frame to tape
dac 1f dac 1f
lac fo lac fo
sys write; 1f; 1 sys write; 1f; 1
@@ -180,37 +194,37 @@ put2: 0
boot: boot:
org = 017740 org = 017740
2: 2:
jms get1-boot+org jms get1-boot+org " get command word from tape
dac cmd-boot+org dac cmd-boot+org
jms get1-boot+org jms get1-boot+org " get count from tape
cma cma
dac cnt-boot+org dac cnt-boot+org " store complemented (incremented below)
jms get2-boot+org jms get2-boot+org " get checksum word
xor sum-boot+org xor sum-boot+org " clear those bits in sum
dzm sum-boot+org dzm sum-boot+org " clear out sum
cla cll sza cla cll sza " checksum match? & clear AC & LINK
hlt hlt " no: checksum mismatch
isz cnt-boot+org isz cnt-boot+org " yes: increment count (complete negate)
1: 1:
jms get1-boot+org jms get1-boot+org " get data word from tape
cmd: 0 cmd: 0 " command word (read from tape)
isz cmd-boot+org isz cmd-boot+org " increment command instruction
isz cnt-boot+org isz cnt-boot+org " increment count
jmp 1b-boot+org jmp 1b-boot+org " not done, keep going
jmp 2b-boot+org jmp 2b-boot+org
get1: 0 get1: 0 " get checksummed word from tape
jms get2-boot+org jms get2-boot+org " read a word
dac get2-boot+org dac get2-boot+org " save (in get2 return addr word!)
add sum-boot+org add sum-boot+org " 1's complement sum
dac sum-boot+org dac sum-boot+org " save sum
lac get2-boot+org lac get2-boot+org " get word back
jmp i get1-boot+org jmp i get1-boot+org " return
get2: 0 get2: 0 " get unchecksummed word from tape
iot 0144 iot 0144 " "rsb" ptr select binary mode
1: 1:
iot 0101 iot 0101 " "rsf" ptr skip if flag set
jmp 1b-boot+org jmp 1b-boot+org " loop until ready
iot 0112 iot 0112 " "rrb" ptr clear flag, or in read buffer
jmp i get2-boot+org jmp i get2-boot+org
sum: 0 sum: 0
cnt = sum+1 cnt = sum+1
@@ -226,12 +240,12 @@ opnerr:
sys write; mes; 2 sys write; mes; 2
jmp loop jmp loop
mes: mes:
040;077012 040;077012 " space, ?, NL
comand: 0 comand: 0
tracmd: 0 tracmd: 0
d1: 1 d1: 1
.17777: 017777 o17777: 017777 " unused?
o77: 077 o77: 077
o200: 0200 o200: 0200
o300: 0300 o300: 0300