]> git.sur5r.net Git - cc65/blob - libsrc/apple2/rwcommon.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / apple2 / rwcommon.s
1 ;
2 ; Oliver Schmidt, 12.01.2005
3 ;
4
5         .export         rwprolog, rwcommon, rwepilog
6         .import         popax
7
8         .include        "zeropage.inc"
9         .include        "errno.inc"
10         .include        "fcntl.inc"
11         .include        "mli.inc"
12         .include        "filedes.inc"
13
14 rwprolog:
15         ; Save count
16         sta     ptr2
17         stx     ptr2+1
18
19         ; Get and save buf
20         jsr     popax
21         sta     ptr1
22         stx     ptr1+1
23
24         ; Get and process fd
25         jsr     popax
26         jmp     getfd           ; Returns A, Y and C
27
28 rwcommon:
29         ; Set fd
30         sta     mliparam + MLI::RW::REF_NUM
31
32         ; Set buf
33         lda     ptr1
34         ldx     ptr1+1
35         sta     mliparam + MLI::RW::DATA_BUFFER
36         stx     mliparam + MLI::RW::DATA_BUFFER+1
37
38         ; Set count
39         lda     ptr2
40         ldx     ptr2+1
41         sta     mliparam + MLI::RW::REQUEST_COUNT
42         stx     mliparam + MLI::RW::REQUEST_COUNT+1
43
44         ; Call read or write
45         tya
46         ldx     #RW_COUNT
47         jsr     callmli
48         bcc     rwepilog
49         cmp     #$4C            ; "End of file encountered"
50         bne     oserr
51
52 rwepilog:
53         ; Return success
54         sta     __oserror       ; A = 0
55         lda     mliparam + MLI::RW::TRANS_COUNT
56         ldx     mliparam + MLI::RW::TRANS_COUNT+1
57         rts
58
59         ; Set __oserror
60 oserr:  jmp     __mappederrno