missing fd_management and cleaning

This commit is contained in:
jede
2022-04-24 00:39:04 +02:00
committed by mrdudz
parent dfab2b27cd
commit 244da9c911
4 changed files with 59 additions and 50 deletions

View File

@@ -2,38 +2,41 @@
; jede jede@oric.org 2017-01-22
;
.export _read
.export _read
.import popax
.import popax
.include "zeropage.inc"
.include "telestrat.inc"
.include "zeropage.inc"
.include "telestrat.inc"
;int read (int fd, void* buf, unsigned count);
.proc _read
sta ptr1 ; Count
stx ptr1+1 ; Count
jsr popax ; Get buf
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
stx ptr2+1 ;
sta PTR_READ_DEST
stx PTR_READ_DEST+1
sta ptr2 ; in order to calculate nb of bytes read
stx ptr2+1
jsr popax ; get FD
lda ptr1 ;
ldy ptr1+1 ;
BRK_TELEMON XFREAD ; calls telemon30 routine
; Compute nb of bytes read
lda PTR_READ_DEST+1
sec
sbc ptr2+1
tax
lda PTR_READ_DEST
sec
sbc ptr2
; Here A and X contains number of bytes read
rts
tax ; send FD to X
lda ptr1
ldy ptr1+1
BRK_TELEMON XFREAD
; compute nb of bytes read
lda PTR_READ_DEST+1
sec
sbc ptr2+1
tax
lda PTR_READ_DEST
sec
sbc ptr2
; here A and X contains number of bytes read
rts
.endproc