]> git.sur5r.net Git - cc65/commitdiff
Invalid error codes will set errno
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 19 Dec 2003 18:45:26 +0000 (18:45 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Fri, 19 Dec 2003 18:45:26 +0000 (18:45 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2784 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/common/strerror.s

index 79bf7127a1f0a1962f35449c8f0dd33a6f95098e..98a5725b186ceba855edb32e3531dad715996028 100644 (file)
@@ -15,12 +15,19 @@ _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
 
+@L2:   asl     a               ; * 2
+       tay
                ldx     __sys_errlist+1,y
        lda     __sys_errlist,y
        rts