1
0
mirror of https://github.com/DoctorWkt/pdp7-unix.git synced 2026-01-25 19:57:20 +00:00

I didn't mean to check the stuff in bin!

This commit is contained in:
Warren Toomey
2016-03-04 14:17:42 +10:00
parent e928dbf7b6
commit 5b9ecc343d
6 changed files with 0 additions and 481 deletions

140
bin/cat
View File

@@ -1,140 +0,0 @@
010000: 237777 lac 017777 i
010001: 550407 sad d4 " Skip if we have more than four argument words
010002: 610052 jmp nofiles " Only four argument words, so no arguments
010003: 217777 lac 017777 " Move five words past the argument word count
010004: 350406 tad d1 " so that AC points at the first argument
010005: 350407 tad d4 " and save the pointer in name
010006: 050010 dac name
010007: 020003 sys open; name:0; 0 " Open file, get fd back
010010: 000000
010011: 000000
010012: 741100 spa
010013: 610035 jmp badfile " Negative fd, exit with an error message
010014: 050301 dac fi " Save file descriptor in fi
010015: 110104 jms getc " Get a character in AC
010016: 550407 sad o4
010017: 610022 jmp 1f " Break the loop when we get a ctrl-D
010020: 110140 jms putc " Write the character on stdout
010021: 610015 jmp 1b " and loop back
010022: 210301 lac fi " Close the file descriptor in fi
010023: 020011 sys close
010024: 777774 -4
010025: 377777 tad 017777 i " Subtract 4 from the count of argument words
010026: 077777 dac 017777 i
010027: 550407 sad d4 " Is the value 4, i.e. no args left?
010030: 610064 jmp done " Yes, so exit
010031: 210010 lac name " Still an argument, so move up
010032: 350407 tad d4 " to the next filename argument
010033: 050010 dac name
010034: 610007 jmp loop " and loop back to cat this file
010035: 210010 lac name " Get the pointer to the filename
010036: 050041 dac 1f " Store it in 1f below
010037: 210410 lac d8 " Load fd 8 which is stderr
010040: 020005 sys write; 1:0; 4 " Write the four words of the filename
010041: 000000
010042: 000004
010043: 210410 lac d8
010044: 020005 sys write; 1f; 2 " and then write " ?\n"
010045: 010050
010046: 000002
010047: 610024 jmp loop1 " Now try doing the next argument
010050: 000040 1: 040;077012 " String literal: " ?\n"
010051: 077012
010052: 210410 lac d8
010053: 020005 sys write; 1f; 5 " Write "No files\n" to stderr
010054: 010057
010055: 000005
010056: 020016 sys exit " and exit
010057: 156157 1: <no>; 040; <fi>;<le>;<s 012
010060: 000040
010061: 146151
010062: 154145
010063: 163012
010064: 210404 lac noc " Is the number of characters left zero?
010065: 741200 sna
010066: 020016 sys exit " Yes, exit
010067: 510406 and d1
010070: 751200 sna cla
010071: 610074 jmp 1f
010072: 110140 jms putc " Store the character in the buffer
010073: 610064 jmp done " and loop back
010074: 210404 lac noc " Get the number of characters in the buffer
010075: 744020 rcr " Divide by two to convert to words
010076: 050102 dac 1f " Save in the write's word count below
010077: 210405 lac fo " Load fd 1, stdout
010100: 020005 sys write; iopt+1; 1:.. " Write the leftover buffer and exit
010101: 010304
010102: 010000
010103: 020016 sys exit
010104: 000000 getc: 0
010105: 210176 lac ipt " Load the pointer to the next word in the buffer
010106: 550177 sad eipt
010107: 610123 jmp 1f " We've reached the end of the buffer, so read more
010110: 050174 dac 2f " Save the pointer
010111: 310411 add o400000 " Flip the msb and save into ipt
010112: 050176 dac ipt
010113: 740010 ral " Move the msb into the link register
010114: 230174 lac 2f i " Load the word from the buffer
010115: 741400 szl " Skip if this is the second character in the word
010116: 660511 lrss 9 " It's the first char, shift down the top character
010117: 510412 and o177 " Keep the lowest 7 bits
010120: 741200 sna
010121: 610105 jmp getc+1 " Skip a NUL characters and read another one
010122: 630104 jmp getc i " Return the character from the subroutine
010123: 210301 lac fi " Buffer is empty, read another 64 characters
010124: 020004 sys read; iipt+1; 64
010125: 010201
010126: 000100
010127: 741200 sna
010130: 610136 jmp 1f " No characters were read in
010131: 350200 tad iipt " Add the word count to the base of the buffer
010132: 050177 dac eipt " and store in the end buffer pointer
010133: 210200 lac iipt " Reset the ipt to the base of the buffer
010134: 050176 dac ipt
010135: 610105 jmp getc+1 " and loop back to get one character
010136: 210407 lac o4 " No character, return with ctrl-D
010137: 630104 jmp getc i " return from subroutine
010140: 000000 putc: 0
010141: 510412 and o177 " Keep the lowest 7 bits and save into 2f+1
010142: 050175 dac 2f+1
010143: 210302 lac opt " Save the pointer to the empty buffer
010144: 050174 dac 2f " position to 2f
010145: 310411 add o400000 " Flip the msb and save back into opt
010146: 050302 dac opt " This also has the effect of incrementing
010147: 741100 spa " If the bit was set, we already have one
010150: 610154 jmp 1f " character at 2f+1. If no previous character,
010151: 230174 lac 2f i " merge the old and new character together
010152: 250175 xor 2f+1
010153: 610156 jmp 3f " and go to the "save it in buffer" code
010154: 210175 lac 2f+1 " Move the character up into the top half
010155: 660711 alss 9
010156: 070174 dac 2f i " Save the word into the buffer
010157: 450404 isz noc " Add 1 to the char count, never skipping
010160: 210404 lac noc " Have we reached 128 characters, 64 words?
010161: 550413 sad d128
010162: 741000 skp
010163: 630140 jmp putc i " No, so return (more room still in the buffer)
010164: 210405 lac fo " Load fd1 (i.e stdout)
010165: 020005 sys write; iopt+1; 64 " and write out the 64 words in the buffer
010166: 010304
010167: 000100
010170: 210303 lac iopt
010171: 050302 dac opt " Set opt pointing back to base of buffer
010172: 150404 dzm noc " Set the number of chars in the buffer to 0
010173: 630140 jmp putc i " and return
010174: 000000 2: 0;0 " Current input and output word pointers
010175: 000000
010176: 000000 ipt: 0 " Current input buffer base
010177: 000000 eipt: 0 " Pointer to end of data read in input buffer
010200: 010201 iipt: .+1; .=.+64 " 64 word input buffer and pointer to it
010301: 000000 fi: 0 " Input file descriptor
010302: 010304 opt: .+2 " Current output buffer base
010303: 010304 iopt: .+1; .=.+64 " 64 word output buffer and pointer to it
010404: 000000 noc: 0 " Number of output characters
010405: 000001 fo: 1 " Output file descriptor, fd 1 is stdout
010406: 000001 d1: 1 " Octal and decimal constants
010407: 000004 o4:d4: 4
010410: 000010 d8: 8
010411: 400000 o400000: 0400000 " Msb toggle bit
010412: 000177 o177: 0177 " ASCII mask
010413: 000200 d128: 128 " 128 words in the output buffer

View File

@@ -1,71 +0,0 @@
010000: 237777 lac 017777 i " Have we got any arguments?
010001: 550101 sad d4
010002: 610073 jmp error " No, give an error
010003: 217777 lac 017777
010004: 350101 tad d4 " Skip past argc
010005: 040010 dac 8 " and save the ptr to the octal value at location 8
010006: 350100 tad d1 " Why only 1 here?
010007: 050053 dac name " Save the filename pointer
010010: 150111 dzm octal " Zero the octal value and
010011: 150107 dzm nchar " the number of characters
010012: 777770 -8 " Set c1 to -8 so we can increment up to zero
010013: 050110 dac c1 " and thus count the number of chars in the argument
010014: 210107 lac nchar " Get any left-over character from the last loop
010015: 150107 dzm nchar " and set nchar to empty now
010016: 740200 sza " It was already empty, so get a new word
010017: 610026 jmp 2f " Not empty, it has the second ASCII value, goto 2f
010020: 220010 lac 8 i " Read the next word with two chars in it
010021: 652000 lmq " Copy it to MQ
010022: 510105 and o177 " Trim off all but the second ASCII value
010023: 050107 dac nchar " Save it into nchar
010024: 641002 lacq " Bring it back from MQ
010025: 660511 lrss 9 " and shift down the first ASCII value
010026: 550104 sad o40 " If the character is a space
010027: 610037 jmp 3f " don't try to make it part of the octal value
010030: 350106 tad om60 " Not a space, subtract 060 i.e. '0'
010031: 652000 lmq " Move it into MQ
010032: 210111 lac octal " Load the octal value up to here
010033: 744000 cll; als 3 " Shift it left 3 bits
010034: 640703
010035: 640002 omq " OR in the digit from MQ
010036: 050111 dac octal " and save back in the octal value
010037: 450110 isz c1 " Is that the last character?
010040: 610014 jmp 1b " No, go back and get another one
010041: 237777 lac 017777 i " How many arguments left?
010042: 550102 sad d8
010043: 020016 sys exit " None, exit
010044: 350103 tad dm4 " Subtract 4 to indicate one less argument
010045: 077777 dac 017777 i " and save for next time
010046: 210053 lac name " Also move to the next filename
010047: 350101 tad d4
010050: 050053 dac name
010051: 210111 lac octal " Set AC to have the new file mode
010052: 020022 sys chmod; name:0 " and change the file's mode
010053: 000000
010054: 740100 sma
010055: 610041 jmp loop " Loop if no error
010056: 210053 lac name " We got back -1, error
010057: 050062 dac 1f " Write out the filename on stdout
010060: 210100 lac d1 " followed by the " ?\n" string
010061: 020005 sys write; 1:0; 4 " and loop back
010062: 000000
010063: 000004
010064: 210100 lac d1
010065: 020005 sys write; 1f; 2
010066: 010071
010067: 000002
010070: 610041 jmp loop
010071: 000040 040;077012 " String literal " ?\n"
010072: 077012
010073: 210100 lac d1 " Write " "\n" to stdout and exit
010074: 020005 sys write; 1b+1; 1
010075: 010072
010076: 000001
010077: 020016 sys exit
010100: 000001 d1: 1 " Numeric constants
010101: 000004 d4: 4
010102: 000010 d8: 8
010103: 777774 dm4: -4
010104: 000040 o40: 040
010105: 000177 o177: 0177
010106: 777720 om60: -060

View File

@@ -1,71 +0,0 @@
010000: 237777 lac 017777 i " Have we got any arguments?
010001: 550101 sad d4
010002: 610073 jmp error " No, give an error
010003: 217777 lac 017777
010004: 350101 tad d4 " Skip past argc
010005: 040010 dac 8 " and save the ptr to the octal value at location 8
010006: 350100 tad d1 " Why only 1 here?
010007: 050053 dac name " Save the filename pointer
010010: 150111 dzm octal " Zero the octal value and
010011: 150107 dzm nchar " the number of characters
010012: 777770 -8 " Set c1 to -8 so we can increment up to zero
010013: 050110 dac c1 " and thus count the number of chars in the argument
010014: 210107 lac nchar " Get any left-over character from the last loop
010015: 150107 dzm nchar " and set nchar to empty now
010016: 740200 sza " It was already empty, so get a new word
010017: 610026 jmp 2f " Not empty, it has the second ASCII value, goto 2f
010020: 220010 lac 8 i " Read the next word with two chars in it
010021: 652000 lmq " Copy it to MQ
010022: 510105 and o177 " Trim off all but the second ASCII value
010023: 050107 dac nchar " Save it into nchar
010024: 641002 lacq " Bring it back from MQ
010025: 660511 lrss 9 " and shift down the first ASCII value
010026: 550104 sad o40 " If the character is a space
010027: 610037 jmp 3f " don't try to make it part of the octal value
010030: 350106 tad om60 " Not a space, subtract 060 i.e. '0'
010031: 652000 lmq " Move it into MQ
010032: 210111 lac octal " Load the octal value up to here
010033: 744000 cll; als 3 " Shift it left 3 bits
010034: 640703
010035: 640002 omq " OR in the digit from MQ
010036: 050111 dac octal " and save back in the octal value
010037: 450110 isz c1 " Is that the last character?
010040: 610014 jmp 1b " No, go back and get another one
010041: 237777 lac 017777 i " How many arguments left?
010042: 550102 sad d8
010043: 020016 sys exit " None, exit
010044: 350103 tad dm4 " Subtract 4 to indicate one less argument
010045: 077777 dac 017777 i " and save for next time
010046: 210053 lac name " Also move to the next filename
010047: 350101 tad d4
010050: 050053 dac name
010051: 210111 lac octal " Set AC to have the new file mode
010052: 020023 sys chown; name:0 " and change the file's owner
010053: 000000
010054: 740100 sma
010055: 610041 jmp loop " Loop if no error
010056: 210053 lac name " We got back -1, error
010057: 050062 dac 1f " Write out the filename on stdout
010060: 210100 lac d1 " followed by the " ?\n" string
010061: 020005 sys write; 1:0; 4 " and loop back
010062: 000000
010063: 000004
010064: 210100 lac d1
010065: 020005 sys write; 1f; 2
010066: 010071
010067: 000002
010070: 610041 jmp loop
010071: 000040 040;077012 " String literal " ?\n"
010072: 077012
010073: 210100 lac d1 " Write " "\n" to stdout and exit
010074: 020005 sys write; 1b+1; 1
010075: 010072
010076: 000001
010077: 020016 sys exit
010100: 000001 d1: 1 " Numeric constants
010101: 000004 d4: 4
010102: 000010 d8: 8
010103: 777774 dm4: -4
010104: 000040 o40: 040
010105: 000177 o177: 0177
010106: 777720 om60: -060

View File

@@ -1,46 +0,0 @@
010000: 217777 lac 017777 " Go to the argc
010001: 350054 tad d5 " Skip past the argc and argv[0]
010002: 050014 dac 1f " Save argv[1] in the chdir arg below
010003: 050026 dac 2f " and in the unlink as well? Yes, we skip it
010004: 237777 lac 017777 i " How many arguments do we have?
010005: 550053 sad d4
010006: 020016 sys exit " None, so exit
010007: 350055 tad dm4 " Subtract 1
010010: 077777 dac 017777 i " and save in the argc
010011: 020021 sys chdir; dd " chdir to dd
010012: 010046
010013: 020021 sys chdir; 1:0 " and then into the first argument
010014: 000000
010015: 237777 lac 017777 i " Any arguments left?
010016: 550053 sad d4
010017: 020016 sys exit " No, exit the program
010020: 350055 tad dm4 " Subtract 4 from the argc and update it
010021: 077777 dac 017777 i
010022: 210026 lac 2f " Move up to the next filename
010023: 350053 tad d4
010024: 050026 dac 2f " and save it in the unlink arg
010025: 020013 sys unlink; 2:0 " Unlink the file
010026: 000000
010027: 740100 sma
010030: 610015 jmp 1b " Loop back if the unlink was OK, or issue err
010031: 210026 lac 2b " Copy the filename pointer below
010032: 050035 dac 2f
010033: 210052 lac d1 " Write the filename on stdout
010034: 020005 sys write; 2:0; 4
010035: 000000
010036: 000004
010037: 210052 lac d1
010040: 020005 sys write; 1f; 2 " Write " ?\n" on stdout
010041: 010044
010042: 000002
010043: 610015 jmp 1b " and loop back
010044: 040077 040077;012000 " String literal " ?\n"
010045: 012000
010046: 144144 <dd>;040040;040040;040040 " Filename dd
010047: 040040
010050: 040040
010051: 040040
010052: 000001 d1: 1
010053: 000004 d4: 4
010054: 000005 d5: 5
010055: 777774 dm4: -4

105
bin/cp
View File

@@ -1,105 +0,0 @@
010000: 217777 lac 017777 " Skip past argc and save
010001: 350137 tad d1 " argv[0] (our name) into name2
010002: 050026 dac name2 " We will skip past it later
010003: 237777 lac 017777 i " Any arguments left?
010004: 550142 sad d4
010005: 020016 sys exit " 4 words = no args left, exit
010006: 550143 sad d8 " Do we have 2 args?
010007: 610123 jmp unbal " No, an unbalanced set of arguments
010010: 350145 tad dm8 " Subtract 8 (two args) from the argc
010011: 077777 dac 017777 i " and save it
010012: 210026 lac name2
010013: 350142 tad d4
010014: 050020 dac name1 " Skipping pairs of filenames? not sure
010015: 350142 tad d4
010016: 050026 dac name2
010017: 020003 sys open; name1: 0; 0 " Open the input file
010020: 000000
010021: 000000
010022: 741100 spa
010023: 610074 jmp error " File open error
010024: 210144 lac o17 " Why load 15 (017) into AC?
010025: 020006 sys creat; name2: 0 " Create the output file
010026: 000000
010027: 741100 spa
010030: 610074 jmp error " File create error
010031: 150147 dzm nin " Set the number of input words to zero
010032: 210150 lac bufp " Set up the base of the upcoming read
010033: 350147 tad nin " to be the buffer + nin so we skip
010034: 050044 dac 0f " the existing words in the buffer
010035: 777777 -1
010036: 350147 tad nin " Calculate 1024 - nin, i.e. the number
010037: 740001 cma " of empty words yet to be filled in the
010040: 350146 tad d1024 " buffer, and use it as the read count
010041: 050045 dac 0f+1
010042: 210140 lac d2 " Read from fd 2: hard-wired in fd!
010043: 020004 sys read; 0:..;..
010044: 010000
010045: 010000
010046: 741200 sna
010047: 610055 jmp 2f " No words were read in, go to 2f
010050: 350147 tad nin " Add the number of words read in
010051: 050147 dac nin " to the existing number of words
010052: 550146 sad d1024
010053: 610055 jmp 2f " We do have 1,024 words, go to 2f
010054: 610032 jmp 1b " Loop back if we don't have 1,024 words
010055: 210147 lac nin " Load the number of words in the input buffer
010056: 050062 dac 2f " Save in the write word count argument
010057: 210141 lac d3 " Write to fd 3: hard-wired out fd!
010060: 020005 sys write; buf; 2:0
010061: 010151
010062: 000000
010063: 150147 dzm nin " Set nin back to zero
010064: 210062 lac 2b " Get the write count (updated by sys write)
010065: 550146 sad d1024 " Did we write the buffer out?
010066: 610032 jmp 1b " Yes, we wrote 1,024 words, so loop back
010067: 210140 lac d2
010070: 020011 sys close " Close fd 2 and fd 3
010071: 210141 lac d3
010072: 020011 sys close
010073: 610003 jmp loop " Loop back to deal with the next arguments
010074: 210020 lac name1 " standard output, fd 1 followed by " ?\n"
010075: 050100 dac 1f
010076: 210137 lac d1
010077: 020005 sys write; 1:0; 4
010100: 000000
010101: 000004
010102: 210137 lac d1
010103: 020005 sys write; mes; 1
010104: 010121
010105: 000001
010106: 210026 lac name2 " Then do the same with name 2
010107: 050112 dac 1f
010110: 210137 lac d1
010111: 020005 sys write; 1: 0; 4
010112: 000000
010113: 000004
010114: 210137 lac d1
010115: 020005 sys write; mes; 2
010116: 010121
010117: 000002
010120: 610003 jmp loop " Loop back to deal with the next arguments
010121: 040000 040000;077012 " String literal: " ?\n"
010122: 077012
010123: 210026 lac name2 " so print out the name after name2
010124: 350142 tad d4 " on standard output followed by " ?\n"
010125: 050130 dac 1f
010126: 210137 lac d1
010127: 020005 sys write; 1: 0; 4
010130: 000000
010131: 000004
010132: 210137 lac d1
010133: 020005 sys write; mes; 2
010134: 010121
010135: 000002
010136: 020016 sys exit
010137: 000001 d1: 1 " Numeric constants
010140: 000002 d2: 2
010141: 000003 d3: 3
010142: 000004 d4: 4
010143: 000010 d8: 8
010144: 000017 o17: 017
010145: 777770 dm8: -8
010146: 002000 d1024: 1024
010147: 000000 nin: 0 " Number of words in the input buffer
010150: 010151 bufp: buf " Pointer to the buffer

48
bin/ls
View File

@@ -1,48 +0,0 @@
010000: 020003 sys open; curdir; 0 " Open up the currect directory
010001: 010046
010002: 000000
010003: 741100 spa
010004: 020016 sys exit " Unable, so die now
010005: 050053 dac fd " Save the fd
010006: 210053 lac fd
010007: 020004 sys read; buf; 64
010010: 010060
010011: 000100
010012: 741100 spa " Skip if result was >= 0
010013: 610043 jmp fileend " Result was -ve, so error result
010014: 741200 sna " Skip if result was >0
010015: 610043 jmp fileend " Result was zero, so nothing left to read
010016: 050056 dac count
010017: 210057 lac ibufptr " Point bufptr at the base of the buffer
010020: 050024 dac bufptr
010021: 450024 isz bufptr " Move up to the filename
010022: 210054 lac d1
010023: 020005 sys write; bufptr:0; 4 " Write a filename out to stdout
010024: 000000
010025: 000004
010026: 210054 lac d1
010027: 020005 sys write; newline; 1 " followed by a newline
010030: 010052
010031: 000001
010032: 210024 lac bufptr " Add 7 to the bufptr
010033: 350055 tad d7
010034: 050024 dac bufptr
010035: 777770 -8
010036: 350056 tad count " Decrement the count of words by 8
010037: 050056 dac count
010040: 740200 sza " Anything left in the buffer to print?
010041: 610021 jmp printloop " Yes, stuff left to print
010042: 610006 jmp fileloop " Nothing in the buffer, try reading some more
010043: 210053 lac fd
010044: 020011 sys close
010045: 020016 sys exit
010046: 056040 curdir: <. 040; 040040; 040040; 040040 " i.e. "."
010047: 040040
010050: 040040
010051: 040040
010052: 012000 newline: 012000
010053: 000000 fd: 0
010054: 000001 d1: 1 " stdout fd
010055: 000007 d7: 7
010056: 000000 count: 0
010057: 010060 ibufptr: buf " Constant pointer to the buffer