2000-05-28 13:40:48 +00:00
|
|
|
;
|
2010-06-10 18:10:53 +00:00
|
|
|
; Ullrich von Bassewitz, 2003-08-12
|
2000-05-28 13:40:48 +00:00
|
|
|
;
|
2010-06-10 18:10:53 +00:00
|
|
|
; Helper functions for several high level file functions.
|
2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
|
2010-06-10 18:10:53 +00:00
|
|
|
.include "errno.inc"
|
|
|
|
|
|
|
|
.code
|
|
|
|
|
|
|
|
; ----------------------------------------------------------------------------
|
|
|
|
; int __fastcall__ _directerrno (unsigned char code);
|
|
|
|
; /* Set errno to a specific error code, clear _oserror and return -1. Used
|
2014-06-30 09:10:35 +00:00
|
|
|
; ** by the library.
|
|
|
|
; */
|
2010-06-10 18:10:53 +00:00
|
|
|
|
|
|
|
__directerrno:
|
|
|
|
jsr __seterrno ; Set errno, returns with A = 0
|
|
|
|
sta __oserror ; Clear __oserror
|
|
|
|
beq fail ; Branch always
|
|
|
|
|
|
|
|
; ----------------------------------------------------------------------------
|
|
|
|
; int __fastcall__ _mappederrno (unsigned char code);
|
|
|
|
; /* Set _oserror to the given platform specific error code. If it is a real
|
2014-06-30 09:10:35 +00:00
|
|
|
; ** error code (not zero) set errno to the corresponding system error code
|
|
|
|
; ** and return -1. Otherwise return zero.
|
|
|
|
; ** Used by the library.
|
|
|
|
; */
|
2010-06-10 18:10:53 +00:00
|
|
|
|
|
|
|
__mappederrno:
|
|
|
|
sta __oserror ; Store the error code
|
|
|
|
tax ; Did we have an error?
|
|
|
|
beq ok ; Branch if no
|
|
|
|
jsr __osmaperrno ; Map os error into errno code
|
|
|
|
jsr __seterrno ; Save in errno
|
|
|
|
fail: lda #$FF ; Return -1
|
|
|
|
tax
|
|
|
|
ok: rts
|
|
|
|
|
|
|
|
|
|
|
|
; ----------------------------------------------------------------------------
|
2000-05-28 13:40:48 +00:00
|
|
|
.bss
|
|
|
|
|
|
|
|
__errno:
|
2013-05-09 11:56:54 +00:00
|
|
|
.word 0
|
2000-05-28 13:40:48 +00:00
|
|
|
|