]> git.sur5r.net Git - cc65/blob - libsrc/common/strerror.s
Fixed _textcolor definition.
[cc65] / libsrc / common / strerror.s
1 ;
2 ; Ullrich von Bassewitz, 17.05.2000
3 ;
4 ; char* __fastcall__ strerror (int errcode);
5 ; /* Map an error number to an error message */
6 ;
7
8         .export         _strerror
9         .import         __sys_errlist
10
11         .include        "errno.inc"
12
13 _strerror:
14         cpx     #$00            ; High byte must be zero
15         bne     @L1             ; Jump if invalid error
16         cmp     #EMAX           ; Valid error code (map EUNKNOWN to 0)?
17         bcc     @L2             ; Jump if ok
18
19 ; The given error code is invalid
20
21 @L1:    lda     #<EINVAL
22         sta     __errno
23         lda     #>EINVAL        ; = 0
24         sta     __errno+1
25 ;       lda     #$00            ; A contains zero: "Unknown error"
26
27 ; Load the pointer to the error message and return
28
29 @L2:    asl     a               ; * 2
30         tay
31         ldx     __sys_errlist+1,y
32         lda     __sys_errlist,y
33         rts
34
35