]> git.sur5r.net Git - cc65/blob - libsrc/atari/read.s
This commit was generated by cvs2svn to compensate for changes in r2,
[cc65] / libsrc / atari / read.s
1 ;
2 ; Christian Groessler, Apr-2000
3 ;
4 ; int read(int fd,void *buf,int count)
5 ;
6
7         .include "atari.inc"
8         .import __rwsetup,__do_oserror,__inviocb,__oserror
9         .export _read
10
11 _read:  jsr     __rwsetup       ; do common setup for read and write
12         beq     done            ; if size 0, it's a no-op
13         cpx     #$FF            ; invalid iocb?
14         beq     _inviocb
15         lda     #GETCHR         ; iocb command code
16         sta     ICCOM,x
17         jsr     CIOV            ; read it
18         bpl     done
19         cpy     #EOFERR         ; eof is treated specially
20         beq     done
21         jmp     __do_oserror    ; update errno
22
23 done:   lda     ICBLL,x         ; buf len lo
24         pha                     ; save
25         lda     ICBLH,x         ; get buf len hi
26         tax                     ; to X
27         lda     #0
28         sta     __oserror       ; clear system dependend error code
29         pla                     ; get buf len lo
30         rts
31
32 _inviocb:
33         jmp     __inviocb