2000-05-28 13:40:48 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 17.05.2000
|
|
|
|
;
|
|
|
|
; char* __fastcall__ strerror (int errcode);
|
|
|
|
; /* Map an error number to an error message */
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _strerror
|
|
|
|
.import __sys_errlist
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "errno.inc"
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
_strerror:
|
2013-05-09 11:56:54 +00:00
|
|
|
cpx #$00 ; High byte must be zero
|
|
|
|
bne @L1 ; Jump if invalid error
|
|
|
|
cmp #EMAX ; Valid error code (map EUNKNOWN to 0)?
|
|
|
|
bcc @L2 ; Jump if ok
|
2003-12-19 18:45:26 +00:00
|
|
|
|
|
|
|
; The given error code is invalid
|
|
|
|
|
|
|
|
@L1: lda #<EINVAL
|
2022-08-28 20:09:44 +00:00
|
|
|
sta ___errno
|
2003-12-19 18:45:26 +00:00
|
|
|
lda #>EINVAL ; = 0
|
2022-08-28 20:09:44 +00:00
|
|
|
sta ___errno+1
|
2013-05-09 11:56:54 +00:00
|
|
|
; lda #$00 ; A contains zero: "Unknown error"
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
; Load the pointer to the error message and return
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
@L2: asl a ; * 2
|
|
|
|
tay
|
|
|
|
ldx __sys_errlist+1,y
|
|
|
|
lda __sys_errlist,y
|
|
|
|
rts
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|