000000: 237777 lac 017777 i 000001: 540407 sad d4 " Skip if we have more than four argument words 000002: 600052 jmp nofiles " Only four argument words, so no arguments 000003: 217777 lac 017777 " Move five words past the argument word count 000004: 340406 tad d1 " so that AC points at the first argument 000005: 340407 tad d4 " and save the pointer in name 000006: 040010 dac name 000007: 000003 sys open; name:0; 0 " Open file, get fd back 000010: 000000 000011: 000000 000012: 741100 spa 000013: 600035 jmp badfile " Negative fd, exit with an error message 000014: 040301 dac fi " Save file descriptor in fi 000015: 100104 jms getc " Get a character in AC 000016: 540407 sad o4 000017: 600022 jmp 1f " Break the loop when we get a ctrl-D 000020: 100140 jms putc " Write the character on stdout 000021: 600015 jmp 1b " and loop back 000022: 200301 lac fi " Close the file descriptor in fi 000023: 000011 sys close 000024: 777774 -4 000025: 377777 tad 017777 i " Subtract 4 from the count of argument words 000026: 077777 dac 017777 i 000027: 540407 sad d4 " Is the value 4, i.e. no args left? 000030: 600064 jmp done " Yes, so exit 000031: 200010 lac name " Still an argument, so move up 000032: 340407 tad d4 " to the next filename argument 000033: 040010 dac name 000034: 600007 jmp loop " and loop back to cat this file 000035: 200010 lac name " Get the pointer to the filename 000036: 040041 dac 1f " Store it in 1f below 000037: 200410 lac d8 " Load fd 8 which is stderr 000040: 000005 sys write; 1:0; 4 " Write the four words of the filename 000041: 000000 000042: 000004 000043: 200410 lac d8 000044: 000005 sys write; 1f; 2 " and then write " ?\n" 000045: 000050 000046: 000002 000047: 600024 jmp loop1 " Now try doing the next argument 000050: 000040 1: 040;077012 " String literal: " ?\n" 000051: 077012 000052: 200410 lac d8 000053: 000005 sys write; 1f; 5 " Write "No files\n" to stderr 000054: 000057 000055: 000005 000056: 000016 sys exit " and exit 000057: 156157 1: ; 040; ;;