]> git.sur5r.net Git - cc65/blob - libsrc/cbm/rwcommon.s
Working on the CBM file functions
[cc65] / libsrc / cbm / rwcommon.s
1 ;
2 ; Ullrich von Bassewitz, 17.11.2002
3 ;
4 ; Common stuff for the read/write routines
5 ;
6
7         .export         rwcommon
8
9         .import         popax
10         .importzp       ptr1, ptr2, ptr3, tmp2
11
12         .include        "filedes.inc"
13
14
15 ;--------------------------------------------------------------------------
16 ; rwcommon: Pop the parameters from stack, preprocess them and place them
17 ; into zero page locations. Return carry set if the handle is invalid,
18 ; return carry clear if it is ok. If the carry is clear, the handle is
19 ; returned in A.
20
21 .proc   rwcommon
22
23         jsr     popax           ; Get count
24         eor     #$FF
25         sta     ptr1
26         txa
27         eor     #$FF
28         sta     ptr1+1          ; Remember -count-1
29
30         jsr     popax           ; Get buf
31         sta     ptr2
32         stx     ptr2+1
33
34         lda     #$00
35         sta     ptr3
36         sta     ptr3+1          ; Clear ptr3
37
38         jsr     popax           ; Get the handle
39         sta     tmp2
40         cpx     #$01
41         bcs     inv
42         cmp     #MAX_FDS
43 inv:    rts
44
45 .endproc
46
47