.export rwcommon
- .import popax
+ .import popax, popptr1
.importzp ptr1, ptr2, ptr3, tmp2
.include "errno.inc"
.proc rwcommon
eor #$FF
- sta ptr1
+ sta ptr2
txa
eor #$FF
- sta ptr1+1 ; Remember -count-1
+ sta ptr2+1 ; Remember -count-1
- jsr popax ; Get buf
- sta ptr2
- stx ptr2+1
+ jsr popptr1 ; Get buf to ptr1, Y=0 by call
- lda #$00
- sta ptr3
- sta ptr3+1 ; Clear ptr3
+ sty ptr3
+ sty ptr3+1 ; Clear ptr3
jsr popax ; Get the handle
cpx #$01
- bcs invhandle
- cmp #MAX_FDS
- bcs invhandle
+ bcs @L9
+ cmp #MAX_FDS ; Set carry if fd too large
sta tmp2
- rts ; Return with carry clear
-
-invhandle:
- lda #EINVAL
- sta __errno
- lda #0
- sta __errno+1
- rts ; Return with carry set
+@L9: rts ; Return with result in carry
.endproc