sys_return: equ $d003 sys_call: equ $d006 console_output: equ $7fe8 mon_pdata: equ $c009 mon_pcrlf: equ $c021 org $a100 ldx #fcb0 jsr sys_call tst fcb0+1 ; read error code bne dir_read_error ldx #fcb1 jsr sys_call tst fcb1+1 ; read error code bne dir_read_error ;; We now have directory in buffer ;; Calculate end of directory buffer ldaa dsects+1 ldab #128 mul asld ; times 2 asld ; times 4 addd #dirbuf std bufend ;; Prepare for printout ldx #dirbuf stx bufptr print_loop: ldx bufptr cpx bufend beq print_end tst ,x ; check if entry is empty beq print_next ldab #16 abx ldaa #$20 jsr console_output jsr print_string ldx bufptr ; check if entry is a directory ldaa ,x bita #64 beq print_nodir ldaa #'/ jsr console_output print_nodir: jsr mon_pcrlf print_next: ldx bufptr ldab #64 abx stx bufptr bra print_loop print_end: prog_end: jmp sys_return * dir_read_error: ldx #txt_read_error jsr mon_pdata bra prog_end * print_string: ldaa ,x beq print_string_e jsr console_output inx bra print_string print_string_e: rts * fcb0: fcb $01 ; check file command fcb 0 ; error code fdb dirstr ; pointer to "." string fcb 0 ; flags dsects: fdb 0 ; sectors fdb 0 ; size MSB (not available for "." entry) fdb 0 ; size LSB (not available for "." entry) fdb 0 ; year (not available for "." entry) fcb 0 ; month (not available for "." entry) fcb 0 ; day (not available for "." entry) fcb 0 ; hours (not available for "." entry) fcb 0 ; minutes (not available for "." entry) fcb 0 ; seconds (not available for "." entry) * fcb1: fcb $10 ; load file command fcb 0 ; error code fdb dirstr ; pointer to "." string fdb dirbuf ; directory buffer * dirstr: fcc "." fcb 0 * txt_read_error: fcc "Directory read error" fcb $0d,$0a,$04 * bufend: fdb 0 ; calculated end of buffer (dir sectors * 512 + dirbuf) bufptr: fdb 0 ; pointer within dirbuf * dirbuf: rmb 4096