]> git.sur5r.net Git - cc65/commitdiff
Fixed errno handling
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 24 Jun 2000 09:02:08 +0000 (09:02 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 24 Jun 2000 09:02:08 +0000 (09:02 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@120 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/common/atexit.s

index 5d94d36fe7d541eb5a83cd55435036396d9be7e2..1751b80630f04677908c22696f0002cdc5360f62 100644 (file)
@@ -9,6 +9,8 @@
        .export         _atexit, doatexit
        .import         __errno, jmpvec
 
+       .include        "errno.inc"
+
 .bss
 ecount:        .byte   0               ; Really an index, inc'ed by 2
 efunc:         .word   0,0,0,0,0       ; 5 exit functions
@@ -39,17 +41,19 @@ _atexit:
 
 ; Error, no space left
 
-E0:    lda     #$FF
-               sta     __errno         ; Use -1 until codes are defined ###
-       sta     __errno+1
-       tax
+E0:    lda     #ENOSPC         ; No space left
+       sta     __errno
+       ldx     #$00
+       stx     __errno+1
+       dex
+       txa
        rts
 
 ; Function called from exit
 
 doatexit:
-       ldy     ecount          ; get index
-       beq     L9              ; jump if done
+       ldy     ecount          ; get index
+       beq     L9              ; jump if done
        dey
        lda     efunc,y
        sta     jmpvec+2