Re: [cc65] Atari File I/O again

Date view Thread view Subject view

From: Christian Groessler (cpg_at_aladdin.de)
Date: 2002-05-16 14:00:39


Hi,

On 05/14/2002 12:36:57 PM MST "Shawn Jefferson" wrote:
>
>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?

The read function returns the # of bytes read, so should 0 in EOF
case. 
I don't know right now whether ICBLL and ICBLH are updated by the CIO
function. If they are not then the bug is in the read function here.

regards,
chris

----------------------------------------------------------------------
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-16 14:01:04 CEST