mirror of
https://github.com/livingcomputermuseum/pdp7-unix.git
synced 2026-02-09 18:01:55 +00:00
I wrote a version of od.
This commit is contained in:
@@ -141,11 +141,11 @@ $(BINDIR)/altmkdir: $(ALTSRC)/wktmkdir.s
|
||||
|
||||
# The commands that did not come from the scans
|
||||
others: dirs $(BINDIR)/sh $(BINDIR)/wktcat $(BINDIR)/wktcp $(BINDIR)/date \
|
||||
$(BINDIR)/ln $(BINDIR)/ls $(BINDIR)/mv $(BINDIR)/stat
|
||||
$(BINDIR)/ln $(BINDIR)/ls $(BINDIR)/mv $(BINDIR)/stat $(BINDIR)/od
|
||||
|
||||
# Alternative other commands: no dd, but . and ..
|
||||
altothers: dirs $(BINDIR)/sh $(BINDIR)/wktcat $(BINDIR)/wktcp $(BINDIR)/date \
|
||||
$(BINDIR)/ln $(BINDIR)/altls $(BINDIR)/mv $(BINDIR)/stat
|
||||
$(BINDIR)/ln $(BINDIR)/altls $(BINDIR)/mv $(BINDIR)/stat $(BINDIR)/od
|
||||
|
||||
|
||||
$(BINDIR)/sh: $(OTHERSRC)/pbsh.s
|
||||
@@ -175,6 +175,9 @@ $(BINDIR)/mv: $(OTHERSRC)/wktmv.s
|
||||
$(BINDIR)/stat: $(OTHERSRC)/wktstat.s
|
||||
$(AS) $(ASARGS) -o $(BINDIR)/stat $(OTHERSRC)/wktstat.s
|
||||
|
||||
$(BINDIR)/od: $(OTHERSRC)/wktod.s
|
||||
$(AS) $(ASARGS) -o $(BINDIR)/od $(OTHERSRC)/wktod.s
|
||||
|
||||
tests:
|
||||
mkdir -p $(TESTDIR)
|
||||
$(AS) $(ASARGS) -o $(TESTDIR)/decimal_out $(TESTSRC)/decimal_out.s
|
||||
|
||||
@@ -33,6 +33,7 @@ dd drwr- -1 4
|
||||
init frwr- -1 bin/init
|
||||
ln frwr- -1 bin/ln
|
||||
ls frwr- -1 bin/ls
|
||||
od frwr- -1 bin/od
|
||||
mv frwr- -1 bin/mv
|
||||
password frw-- -1 fs/password
|
||||
sh frwr- -1 bin/sh
|
||||
|
||||
109
src/other/wktod.s
Normal file
109
src/other/wktod.s
Normal file
@@ -0,0 +1,109 @@
|
||||
" Warren's version of od: od filename
|
||||
"
|
||||
|
||||
main:
|
||||
lac 017777 i " Do we have any arguments?
|
||||
sad d4
|
||||
jmp noarg " No, an error
|
||||
|
||||
lac 017777 " Move five words past the argument word count
|
||||
tad d5 " so that AC points at the first argument
|
||||
dac argptr
|
||||
|
||||
sys open; argptr:0; 0 " Open up the file, save the file descriptor
|
||||
spa
|
||||
jmp badfile
|
||||
dac fd
|
||||
|
||||
lineloop:
|
||||
lac fd
|
||||
sys read; buf; 8 " Read 8 words from the file
|
||||
sna
|
||||
sys exit " Nothing read, exit now
|
||||
dac count
|
||||
|
||||
lac offset " Print out the offset
|
||||
jms octal;
|
||||
lac fd1
|
||||
sys write; colon; 1 " Write colon space
|
||||
lac ibufptr
|
||||
dac bufptr " Start at the beginning of the buffer
|
||||
|
||||
|
||||
printloop:
|
||||
lac bufptr i " Print out the next word
|
||||
jms octal;
|
||||
lac fd1
|
||||
sys write; space; 1 " Write a space
|
||||
-1
|
||||
tad count " Decrement the count
|
||||
dac count
|
||||
sna
|
||||
jmp endofline " Nothing left to print
|
||||
isz bufptr
|
||||
jmp printloop
|
||||
|
||||
|
||||
endofline:
|
||||
lac fd1
|
||||
sys write; newline; 1 " Write a space
|
||||
lac d8
|
||||
tad offset " Bump up the offset
|
||||
dac offset
|
||||
jmp lineloop
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
octal: 0
|
||||
lmq " Move the argument into MQ
|
||||
-6
|
||||
dac c " Set the loop count to 6
|
||||
1:
|
||||
cla
|
||||
llss 3 " Shift 3 more bits into AC
|
||||
tad o60 " Add AC to ASCII '0'
|
||||
dac cbuf " and print out the digit
|
||||
lac fd1
|
||||
sys write; cbuf; 1
|
||||
isz c " Any more characters to print out?
|
||||
jmp 1b " Yes, loop back
|
||||
jmp octal i " and return from subroutine
|
||||
|
||||
|
||||
noarg:
|
||||
" Print a "no arg" error and exit
|
||||
lac d1
|
||||
sys write; noargstr; 4
|
||||
sys exit
|
||||
noargstr: <no>; < a>; <rg>; 012
|
||||
|
||||
badfile:
|
||||
lac argptr " Get the pointer to the argument
|
||||
dac 1f " Store it in 1f below
|
||||
lac d1
|
||||
sys write; 1:0; 4 " Write the name, max 4 words
|
||||
lac d1 " Then write " ?\n"
|
||||
sys write; 1f; 2
|
||||
sys exit " and exit
|
||||
1: 040; 077012 " String literal: " ?\n"
|
||||
|
||||
ibufptr: buf
|
||||
bufptr: buf
|
||||
buf: .=.+8 " Buffer of eight words
|
||||
count: 0 " Count of words read in
|
||||
offset: 0 " Offset from the beginning of file
|
||||
cbuf: 0 " Used to print out in the octal routing
|
||||
c: .=.+1 " Loop counter for printing octal digits
|
||||
fd: 0
|
||||
|
||||
fd1: d1: 1
|
||||
d4: 4
|
||||
d5: 5
|
||||
d8: 8
|
||||
o60: 060
|
||||
|
||||
colon: 072040 " Colon space string
|
||||
space: 040 " Space string
|
||||
newline: 012 " Newline string
|
||||
Reference in New Issue
Block a user