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; ;;