1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-12 07:07:19 +00:00
cc65/libsrc/apple2/rwcommon.s
cuz feacac1394 POSIX file I/O by Oliver Schmidt
git-svn-id: svn://svn.cc65.org/cc65/trunk@3457 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-04-12 09:12:48 +00:00

60 lines
1.2 KiB
ArmAsm

;
; Oliver Schmidt, 12.01.2005
;
.export rwprolog, rwcommon, rwepilog
.import oserrexit
.import popax
.include "zeropage.inc"
.include "fcntl.inc"
.include "mli.inc"
.include "filedes.inc"
rwprolog:
; Save count
sta ptr2
stx ptr2+1
; Get and save buf
jsr popax
sta ptr1
stx ptr1+1
; 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"
bne oserr
rwepilog:
; Return success
lda mliparam + MLI::RW::TRANS_COUNT
ldx mliparam + MLI::RW::TRANS_COUNT+1
rts
; Return oserror
oserr: jmp oserrexit