]> git.sur5r.net Git - cc65/blobdiff - libsrc/common/strerror.s
The IRQ handler needs to save the registers. By Stefan Haubenthal.
[cc65] / libsrc / common / strerror.s
index 6149c42fc20fddc697268a8845f0f44fe2e2c4f6..98a5725b186ceba855edb32e3531dad715996028 100644 (file)
@@ -15,14 +15,20 @@ _strerror:
                bne     @L1             ; Jump if invalid error
        cmp     #EMAX           ; Valid error code (map EUNKNOWN to 0)?
        bcc     @L2             ; Jump if ok
-@L1:   lda     #$00            ; "Unknown error"
-@L2:   asl     a               ; * 2
-       tay
+
+; The given error code is invalid
+
+@L1:    lda     #<EINVAL
+        sta     __errno
+        lda     #>EINVAL        ; = 0
+        sta     __errno+1
+;       lda    #$00            ; A contains zero: "Unknown error"
 
 ; Load the pointer to the error message and return
 
-       lda     __sys_errlist+1,y
-       tax
+@L2:   asl     a               ; * 2
+       tay
+               ldx     __sys_errlist+1,y
        lda     __sys_errlist,y
        rts