]> git.sur5r.net Git - cc65/blob - libsrc/common/oserrcheck.s
Replaced putchar by an assembler version
[cc65] / libsrc / common / oserrcheck.s
1 ;
2 ; Ullrich von Bassewitz, 2003-08-12
3 ;
4 ; Helper function for several high level file functions.
5 ;
6 ; The function will store the value in A into _oserror. If the value is not
7 ; zero, it is translated into a standard error number which is then stored
8 ; into errno, and -1 is returned in a/x. If the value in A was zero, errno
9 ; is not changed, and zero is returned in a/x.
10 ;
11
12         .export         oserrcheck
13
14         .include        "errno.inc"
15
16 .proc   oserrcheck
17
18         sta     __oserror               ; Store the error code
19         tay                             ; Did we have an error?
20         beq     ok                      ; Branch if no
21         jsr     __osmaperrno            ; Map os error into errno code
22         sta     __errno
23         stx     __errno+1               ; Save in errno
24         lda     #$FF                    ; Return -1
25
26 ; Error free, A contains zero
27
28 ok:     tax                             ; Make high byte also zero
29         rts
30
31 .endproc
32
33
34