File: rwcommon.s

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (58 lines) | stat: -rw-r--r-- 1,383 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
;
; Oliver Schmidt, 12.01.2005
;

        .export         rwprolog, rwcommon, rwepilog
        .import         popax, popptr1

        .include        "zeropage.inc"
        .include        "errno.inc"
        .include        "fcntl.inc"
        .include        "mli.inc"
        .include        "filedes.inc"

rwprolog:
        ; Save count
        sta     ptr2
        stx     ptr2+1

        ; Get and save buf
        jsr     popptr1

        ; Get and process fd
        jsr     popax
        jmp     getfd           ; Returns A, Y and C

rwcommon:
        ; Set fd
        sta     mliparam + MLI::RW::REF_NUM

        ; Set buf
        lda     ptr1
        ldx     ptr1+1
        sta     mliparam + MLI::RW::DATA_BUFFER
        stx     mliparam + MLI::RW::DATA_BUFFER+1

        ; Set count
        lda     ptr2
        ldx     ptr2+1
        sta     mliparam + MLI::RW::REQUEST_COUNT
        stx     mliparam + MLI::RW::REQUEST_COUNT+1

        ; Call read or write
        tya
        ldx     #RW_COUNT
        jsr     callmli
        bcc     rwepilog
        cmp     #$4C            ; "End of file encountered"
        bne     oserr

rwepilog:
        ; Return success
        sta     __oserror       ; A = 0
        lda     mliparam + MLI::RW::TRANS_COUNT
        ldx     mliparam + MLI::RW::TRANS_COUNT+1
        rts

        ; Set __oserror
oserr:  jmp     __mappederrno