/ Loads and displays a directory listing / Uses a particular feature of my UNIX-end file daemon mov pc,r1 / Our current address clrb r1 / Ignore low byte add $124,r1 / Magic offset to string below mov $15,-(sp) / Non kernel library 104434 / trap #0 add $2,sp / Fix the stack mov r0,r2 / Address of non-kernel jump-table mov 20(r2),r3 / Function number 10 (open) mov r1,r0 / Address of filename (below) jsr pc,(r3) / LIB_open tst r0 / Test for success beq dirf / failed :-( mov r0,r3 / r3 is now the file handle dirl: mov r3,r1 / Using this stream... mov 2(r2),r4 / Function 1 (read) jsr pc,(r4) / LIB_read cmp r0,$403 / Read failed? beq dirc / yes - close file and exit mov $1,r1 / Print to stdout mov 0(r2),r4 / Function 0 (write) jsr pc,(r4) / LIB_write br dirl / ...and read some more. dirc: mov 22(r2),r4 / Function 11 (close) jsr pc,(r4) / LIB_close dirf: rts pc <_dir\0>