sys_return: equ $d003 sys_call: equ $d006 console_output: equ $7fe8 mon_pdata: equ $c009 mon_out2hs: equ $c012 mon_out4hs: equ $c015 mon_pcrlf: equ $c021 org $a100 ;;; Go to first argument str_skp_next: ldaa ,x beq str_skp_next_e cmpa #$20 beq str_skp_next_1 inx bra str_skp_next str_skp_next_1: ldaa ,x beq str_skp_next_e cmpa #$20 bne str_skp_next_e inx bra str_skp_next_1 str_skp_next_e: * ;;; Save filename (first argument) * ldx #tstnam stx fname0 stx fname1 * ldx #fcb0 jsr sys_call tst fcb0+1 ; read error code bne file_not_found ldx #fcb1 jsr sys_call tst fcb1+1 ; read error code bne file_read_error ;;; Check file ldaa fcb0+4 ; get flags bita #$40 bne file_is_directory ;;; Calculate end of file in memory ldx fcb0+9 ldab #$ff abx stx eaddr ;;; Print file ldx #0 stx pos ldx #$0100 clrb print_loop: jsr mon_out2hs ; Print hex, space and inc x incb cmpb #$10 ; Columns bne print_loop_next clrb jsr mon_pcrlf print_loop_next: cpx eaddr bls print_loop jsr mon_pcrlf prog_end: jmp sys_return * file_not_found: ldx #txt_not_found jsr mon_pdata bra prog_end file_read_error: ldx #txt_read_error jsr mon_pdata bra prog_end file_is_directory: ldx #txt_is_directory jsr mon_pdata bra prog_end * fcb0: fcb $01 ; command fcb 0 ; error code fname0: fdb 0 ; file name fcb 0 ; flags fdb 0 ; sectors fdb 0 ; size MSB fdb 0 ; size LSB fdb 0 ; year fcb 0 ; month fcb 0 ; day fcb 0 ; hours fcb 0 ; minutes fcb 0 ; seconds * fcb1: fcb $10 ; command fcb 0 ; error code fname1: fdb 0 ; file name fdb $0100 ; destination address * txt_not_found: fcc "File not found" fcb $0d,$0a,$04 txt_read_error: fcc "File read error" fcb $0d,$0a,$04 txt_is_directory: fcc "Entry is a directory" fcb $0d,$0a,$04 * eaddr: rmb 2 pos: rmb 2 * *tstnam: * fcc "testfile" * fcb 0 *