]> git.sur5r.net Git - cc65/blob - libsrc/common/strerror.s
Replace strdup by an assembler implementation
[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 @L1:    lda     #$00            ; "Unknown error"
19 @L2:    asl     a               ; * 2
20         tay
21
22 ; Load the pointer to the error message and return
23
24         lda     __sys_errlist+1,y
25         tax
26         lda     __sys_errlist,y
27         rts
28
29