]> git.sur5r.net Git - cc65/blob - libsrc/vic20/read.s
Added VIC20 port changes from Steve Schmidtke
[cc65] / libsrc / vic20 / read.s
1 ;
2 ; Ullrich von Bassewitz, 30.05.1998
3 ;
4 ; int read (int fd, void* buf, int count);
5 ;
6 ; THIS IS A HACK!
7 ;
8
9         .export         _read
10         .import         popax
11         .importzp       ptr1, ptr2, ptr3
12
13         .include        "../cbm/cbm.inc"
14
15 _read:  jsr     popax           ; get count
16         sta     ptr2
17         stx     ptr2+1          ; save it for later
18         jsr     popax           ; get buf
19         sta     ptr1
20         stx     ptr1+1
21         jsr     popax           ; get fd and discard it
22         lda     #0
23         sta     ptr3
24         sta     ptr3+1          ; set count
25
26 L1:     lda     ptr2
27         ora     ptr2+1          ; count zero?
28         beq     L9
29         dec     ptr2
30         bne     L1a
31         dec     ptr2+1
32 L1a:    jsr     BASIN
33         ldy     #0
34         sta     (ptr1),y        ; save char
35         inc     ptr1
36         bne     L2
37         inc     ptr1+1
38 L2:     inc     ptr3            ; increment count
39         bne     L3
40         inc     ptr3+1
41 L3:     cmp     #$0D            ; CR?
42         bne     L1
43
44 ; Done, return the count
45
46 L9:     lda     ptr3
47         ldx     ptr3+1
48         rts
49
50
51