[cc65] Atari File I/O again

Date view Thread view Subject view

From: Shawn Jefferson (sjefferson_at_sd62.bc.ca)
Date: 2002-05-14 21:36:57


Hi there,

I was playing around with the Atari file routines a little bit more and I don't think that feof is working properly.

I created a test program that:
1. creates file, writes into it, closes it.
2. opens the file for r/w, reads until feof, then writes to the file.

However, the program doesn't signal FEOF ever, and the the program just keeps reading from the file past the end until the emulator locks up or I hit RESET.

Here is the code for read.s in the atari library:

_read:  jsr     __rwsetup       ; do common setup for read and write
        beq     done            ; if size 0, it's a no-op
        cpx     #$FF            ; invalid iocb?
        beq     _inviocb
        lda     #GETCHR         ; iocb command code
        sta     ICCOM,x
        jsr     CIOV            ; read it
        bpl     done
        cpy     #EOFERR         ; eof is treated specially
        beq     done
        jmp     __do_oserror    ; update errno

done:   lda     ICBLL,x         ; buf len lo
        pha                     ; save
        lda     ICBLH,x         ; get buf len hi
        tax                     ; to X
        lda     #0
        sta     __oserror       ; clear system dependend error code
        pla                     ; get buf len lo
        rts

_inviocb:
        jmp     __inviocb


I took a look into the source, and I don't fully understand it, but shouldn't read.s in the atari library be setting a flag for EOF in the file pointer structure somehow, instead of just BEQing to done?

Thanks,
Shawn


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2002-05-14 21:37:46 CEST