This commit was generated by cvs2svn to compensate for changes in r2,
which included commits to RCS files with non-trunk default branches. git-svn-id: svn://svn.cc65.org/cc65/trunk@3 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
81
libsrc/common/fmisc.s
Normal file
81
libsrc/common/fmisc.s
Normal file
@@ -0,0 +1,81 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 31.05.1998
|
||||
;
|
||||
; Several small file stream functions
|
||||
;
|
||||
|
||||
.export _clearerr, _feof, _ferror, _fileno, _fflush
|
||||
.import return0
|
||||
.import __errno
|
||||
.importzp ptr1
|
||||
|
||||
;
|
||||
; Get the FILE* parameter, check if the file is open
|
||||
;
|
||||
|
||||
getf: sta ptr1
|
||||
stx ptr1+1
|
||||
ldy #1
|
||||
lda (ptr1),y ; get f->f_flags
|
||||
and #$01 ; file open?
|
||||
beq @L1 ; jump if no
|
||||
clc ; ok
|
||||
rts
|
||||
@L1: sec
|
||||
rts
|
||||
|
||||
;
|
||||
; void clearerr (FILE* f);
|
||||
;
|
||||
|
||||
_clearerr:
|
||||
jsr getf
|
||||
bcs err
|
||||
lda (ptr1),y
|
||||
and #$F9
|
||||
sta (ptr1),y
|
||||
err: rts
|
||||
|
||||
;
|
||||
; int feof (FILE* f);
|
||||
;
|
||||
|
||||
_feof:
|
||||
jsr getf
|
||||
; bcs err
|
||||
lda (ptr1),y
|
||||
and #$02
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
;
|
||||
; int ferror (FILE* f);
|
||||
;
|
||||
|
||||
_ferror:
|
||||
jsr getf
|
||||
; bcs err
|
||||
lda (ptr1),y
|
||||
and #$04
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
;
|
||||
; int fileno (FILE* f);
|
||||
;
|
||||
|
||||
_fileno:
|
||||
jsr getf
|
||||
; bcs err
|
||||
dey
|
||||
lda (ptr1),y
|
||||
ldx #0
|
||||
rts
|
||||
|
||||
;
|
||||
; int __fastcall__ fflush (FILE* f);
|
||||
;
|
||||
|
||||
_fflush = return0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user