]> git.sur5r.net Git - cc65/blob - libsrc/apple2/rwcommon.s
atari5200.sgml: small fix for last change
[cc65] / libsrc / apple2 / rwcommon.s
1 ;
2 ; Oliver Schmidt, 12.01.2005
3 ;
4
5         .export         rwprolog, rwcommon, rwepilog
6         .import         popax, popptr1
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     popptr1
21
22         ; Get and process fd
23         jsr     popax
24         jmp     getfd           ; Returns A, Y and C
25
26 rwcommon:
27         ; Set fd
28         sta     mliparam + MLI::RW::REF_NUM
29
30         ; Set buf
31         lda     ptr1
32         ldx     ptr1+1
33         sta     mliparam + MLI::RW::DATA_BUFFER
34         stx     mliparam + MLI::RW::DATA_BUFFER+1
35
36         ; Set count
37         lda     ptr2
38         ldx     ptr2+1
39         sta     mliparam + MLI::RW::REQUEST_COUNT
40         stx     mliparam + MLI::RW::REQUEST_COUNT+1
41
42         ; Call read or write
43         tya
44         ldx     #RW_COUNT
45         jsr     callmli
46         bcc     rwepilog
47         cmp     #$4C            ; "End of file encountered"
48         bne     oserr
49
50 rwepilog:
51         ; Return success
52         sta     __oserror       ; A = 0
53         lda     mliparam + MLI::RW::TRANS_COUNT
54         ldx     mliparam + MLI::RW::TRANS_COUNT+1
55         rts
56
57         ; Set __oserror
58 oserr:  jmp     __mappederrno