diff --git a/src/other/Readme b/src/other/Readme new file mode 100644 index 0000000..9b2c5da --- /dev/null +++ b/src/other/Readme @@ -0,0 +1,2 @@ +This directory holds other source code for PDP-7 Unix, e.g. rewritten versions +of utilities that did not come from the original scans. diff --git a/tools/wktcat.s b/tools/wktcat.s deleted file mode 100644 index 6c53f41..0000000 --- a/tools/wktcat.s +++ /dev/null @@ -1,116 +0,0 @@ -" Warren's cat program: cat [arg1 arg2 ...] -" -" Because the a7out simulator currently doesn't deal with ASCII files, -" here is how you can test it: -" ./as7 wktcat.s > a.out -" -" ./a7out a.out > z1 -" -" -" ./a7out a.out z1 z1 -" - -main: - " Load the pointer pointer in 017777 to see if we have any arguments - lac 017777 i - sad d4 " Skip if we have more than four argument words - jmp stdinout " Only four argument words, so no arguments - - lac 017777 " Move five words past the argument word count - tad d1 " so that AC points at the first argument - tad d4 - -" This section opens files and copies their contents to standard output -catfiles: - " We start with AC pointing to an argument. Save it at the "name" label - dac name - - " Open the file and get the fd into AC - sys open; name:0; 0; - spa - jmp badfile " Negative fd, exit with an error message - dac fd " Save the file descriptor - -fileloop: - " Read five words into the buffer from the input file - " Five was chosen arbitrarily - lac fd - sys read; buf; 5 - spa " Skip if result was >= 0 - jmp error " Result was -ve, so error result - sna " Skip if result was >0 - jmp fileend " Result was zero, so nothing left to read - - " Save the count of words read in - dac 1f - - " Write five words from the buffer to stdout - lac d1 - sys write; buf; 1:0 - - " and loop back for more words to read - jmp fileloop - -fileend: - " Close the open file descriptor - lac fd - sys close - - " Subtract 4 from the count of argument words - lac minus4 - tad 017777 i - dac 017777 i - sad d4 " Is the value 4, i.e. no args left? - jmp end " Yes, so exit - - " Still an argument, so move up to the next filename argument - lac name - tad d4 - dac name - jmp catfiles " and loop back to cat this file - -end: - " exit - sys exit - -" This section copies from standard input to standard output -" We cheat by setting the fd value to zero and storing 8 -" into the argc word count, so that when the code hits -" fileend, the word count drops to 4 and we exit. -stdinout: - lac d8 - dac 017777 i " Save 8 into the word count - lac d0 - dac fd " Save file descriptor 0 - jmp fileloop - -" This code comes from the real cat.s -badfile: - lac name " Get the pointer to the filename - dac 1f " Store it in 1f below - lac d8 " Load fd 8 which is stderr - sys write; 1:0; 4 " Write the name, max 4 words - lac d8 " Then write " ?\n" - sys write; 1f; 2 - sys exit " and exit - -1: 040; 077012 " String literal: " ?\n" - -error: - " Print an "err read" string on stderr and exit - lac d8 - sys write; noreadstr; 5 - sys exit - -noreadstr: - ;;;012000 - -fd: 0 " fd of the open file -d0: 0 " Constants 0, 1, 4 and 8 -d1: 1 -d4: 4 -d8: 8 " stderr seems to have fd 8 -minus4: 0777774 " Constant -4 - -" Input buffer for read -buf: 0; 0; 0; 0; 0 diff --git a/tools/wktcp.s b/tools/wktcp.s deleted file mode 100644 index 387e7b8..0000000 --- a/tools/wktcp.s +++ /dev/null @@ -1,111 +0,0 @@ -" Warren's cp program: cp arg1 arg2 - -main: - " Load the pointer pointer in 017777 to see if we have any arguments - lac 017777 i - sad d12 - jmp 1f " We have 12 words, so we have 2 arguments - jmp argserror " Otherwise, print an error and exit - -1: lac 017777 " Move five words past the argument word count - tad d5 " so that AC points at the first argument - - " Save the pointer to the file name - dac name - - " Open the input file and get the fd into AC - sys open; name:0; 0; - spa - jmp badfile " Negative fd, exit with an error message - dac infd " Save the file descriptor - - lac 017777 " Move nine words past the argument word count - tad d9 " so that AC points at the second argument - dac name - dac name2 - - " Open the ouput file and get the fd into AC - sys open; name2:0; 1; - spa - jmp badfile " Negative fd, exit with an error message - dac outfd " Save the file descriptor - -fileloop: - " Read five words into the buffer from the input file - " Five was chosen arbitrarily - lac infd - sys read; buf; 5 - spa " Skip if result was >= 0 - jmp readerror " Result was -ve, so error result - sna " Skip if result was >0 - jmp fileend " Result was zero, so nothing left to read - - " Save the count of words read in - dac 1f - - " Write five words from the buffer to the output file - lac outfd - sys write; buf; 1:0 - spa " Skip if result was >= 0 - jmp writeerror " Result was -ve, so error result - - " and loop back for more words to read - jmp fileloop - -fileend: - " Close the open file descriptors - lac infd - sys close - lac outfd - sys close - sys exit - -" This code comes from the real cat.s -badfile: - lac name " Get the pointer to the filename - dac 1f " Store it in 1f below - lac d8 " Load fd 8 which is stderr - sys write; 1:0; 4 " Write the name, max 4 words - lac d8 " Then write " ?\n" - sys write; 1f; 2 - sys exit " and exit - -1: 040; 077012 " String literal: " ?\n" - -readerror: - " Print an "err read" string on stderr and exit - lac d8 - sys write; noreadstr; 5 - sys exit - -noreadstr: - ;;;012000 - -writeerror: - " Print an "err write" string on stderr and exit - lac d8 - sys write; nowritestr; 6 - sys exit - -nowritestr: - ;;;;;;012000 - - -infd: 0 " fd of the input file -outfd: 0 " fd of the output file -d5: 5 -d9: 9 -d8: 8 " stderr seems to have fd 8 -d12: 12 - -" Input buffer for read -buf: .=.+5 diff --git a/tools/write_test.s b/tools/write_test.s deleted file mode 100644 index 6a1ea8e..0000000 --- a/tools/write_test.s +++ /dev/null @@ -1,61 +0,0 @@ -" Test program for several system calls: open, read, write, close, exit -" Do: -" ./as7 write_test.s > a.out -" ./a7out -d a.out -main: - " Test the lac, dac instructions - lac in - dac out - - " Write hello to fd1 i.e stdout - lac d1 - sys write; hello; 7 - - " Test if the assembler can dac into a mid-line label - lac helloptr - dac 1f - lac d1 - sys write; 1:0; 7 - - " Try to open file fred - sys open; fred; 0; 0 - - " read 5 words into the buffer from stdin: type in 10 or more characters! - lac d0 - sys read; buf; 5 - - " Stop and dump memory, so you can see five words at location 0400 - " Comment out the hlt instruction to test close and exit - hlt - - " close stdin - lac d0 - sys close - - " exit - sys exit - - " We should not get to the halt instruction - hlt - - -" Some memory locations for lac and dac -. = 0100 -in: 023 - -. = 0200 -out: 0 - -" Hello, world\n, two ASCII chars per word -hello: ; ; 040; ; ;