Merge pull request #1729 from jedeoric/fix_fd_cleaning_telestrat
[Telestrat] missing fd_management and cleaning
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
; jede jede@oric.org 2017-01-22
|
||||
|
||||
.export _close
|
||||
.export _close
|
||||
|
||||
.import addysp,popax
|
||||
.import addysp,popax
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "telestrat.inc"
|
||||
.include "errno.inc"
|
||||
.include "fcntl.inc"
|
||||
.include "zeropage.inc"
|
||||
.include "telestrat.inc"
|
||||
.include "errno.inc"
|
||||
.include "fcntl.inc"
|
||||
|
||||
; int open (const char* name, int flags, ...); /* May take a mode argument */
|
||||
; int __fastcall__ close (int fd);
|
||||
.proc _close
|
||||
BRK_TELEMON XCLOSE ; launch primitive ROM
|
||||
rts
|
||||
BRK_TELEMON XCLOSE ; Launch primitive ROM
|
||||
rts
|
||||
.endproc
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
.export _write
|
||||
.import popax, popptr1
|
||||
.importzp ptr1, ptr2, ptr3, tmp1
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "telestrat.inc"
|
||||
|
||||
; int write (int fd, const void* buf, int count);
|
||||
@@ -20,7 +20,10 @@
|
||||
stx ptr2 ; save count with each byte incremented separately
|
||||
|
||||
jsr popptr1 ; get buf
|
||||
jsr popax ; get fd and discard
|
||||
|
||||
jsr popax ; get fd
|
||||
|
||||
sta tmp1 ; save fd
|
||||
|
||||
; if fd=0001 then it stdout
|
||||
cpx #0
|
||||
@@ -37,6 +40,7 @@ next:
|
||||
sta PTR_READ_DEST+1
|
||||
lda ptr3
|
||||
ldy ptr3+1
|
||||
ldx tmp1 ; send fd in X
|
||||
BRK_TELEMON XFWRITE
|
||||
; compute nb of bytes written
|
||||
|
||||
@@ -74,7 +78,7 @@ L3:
|
||||
inc ptr1+1
|
||||
jmp L1
|
||||
|
||||
; No error, return count
|
||||
; no error, return count
|
||||
|
||||
L9: lda ptr3
|
||||
ldx ptr3+1
|
||||
|
||||
Reference in New Issue
Block a user