diff --git a/bin/cat b/bin/cat deleted file mode 100644 index a8b1188..0000000 --- a/bin/cat +++ /dev/null @@ -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: ; 040; ;;;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 diff --git a/bin/cp b/bin/cp deleted file mode 100644 index 5416956..0000000 --- a/bin/cp +++ /dev/null @@ -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 diff --git a/bin/ls b/bin/ls deleted file mode 100644 index eb959f0..0000000 --- a/bin/ls +++ /dev/null @@ -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