1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00
cc65/libsrc/telestrat/read.s

44 lines
895 B
ArmAsm
Raw Normal View History

;
; jede jede@oric.org 2017-01-22
;
2022-04-23 22:39:04 +00:00
.export _read
2022-04-23 22:39:04 +00:00
.import popax
2022-04-23 22:39:04 +00:00
.include "zeropage.inc"
.include "telestrat.inc"
2019-02-05 22:27:52 +00:00
2017-02-01 23:11:11 +00:00
;int read (int fd, void* buf, unsigned count);
.proc _read
2022-04-23 22:39:04 +00:00
sta ptr1 ; count
stx ptr1+1 ; count
jsr popax ; get buf
sta PTR_READ_DEST
stx PTR_READ_DEST+1
sta ptr2 ; in order to calculate nb of bytes read
2022-04-24 13:15:10 +00:00
stx ptr2+1
2022-04-23 22:39:04 +00:00
jsr popax ; get FD
tax ; send FD to X
lda ptr1
2022-04-24 13:15:10 +00:00
ldy ptr1+1
BRK_TELEMON XFREAD
2022-04-23 22:39:04 +00:00
; compute nb of bytes read
sec
2023-05-23 21:15:23 +00:00
lda PTR_READ_DEST
sbc ptr2
2023-05-25 16:09:03 +00:00
pha
2023-05-23 21:15:23 +00:00
lda PTR_READ_DEST+1
sbc ptr2+1
tax
2023-05-25 16:09:03 +00:00
pla
2022-04-23 22:39:04 +00:00
rts
.endproc