]> git.sur5r.net Git - cc65/blob - libsrc/common/errno.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / common / errno.s
1 ;
2 ; Ullrich von Bassewitz, 2003-08-12
3 ;
4 ; Helper functions for several high level file functions.
5 ;
6
7
8         .include        "errno.inc"
9
10 .code
11
12 ; ----------------------------------------------------------------------------
13 ; int __fastcall__ _directerrno (unsigned char code);
14 ; /* Set errno to a specific error code, clear _oserror and return -1. Used
15 ;  * by the library.
16 ;  */
17
18 __directerrno:
19         jsr     __seterrno              ; Set errno, returns with A = 0
20         sta     __oserror               ; Clear __oserror
21         beq     fail                    ; Branch always
22
23 ; ----------------------------------------------------------------------------
24 ; int __fastcall__ _mappederrno (unsigned char code);
25 ; /* Set _oserror to the given platform specific error code. If it is a real
26 ;  * error code (not zero) set errno to the corresponding system error code
27 ;  * and return -1. Otherwise return zero.
28 ;  * Used by the library.
29 ;  */
30
31 __mappederrno:
32         sta     __oserror               ; Store the error code
33         tax                             ; Did we have an error?
34         beq     ok                      ; Branch if no
35         jsr     __osmaperrno            ; Map os error into errno code
36         jsr     __seterrno              ; Save in errno
37 fail:   lda     #$FF                    ; Return -1
38         tax
39 ok:     rts
40
41
42 ; ----------------------------------------------------------------------------
43 .bss
44
45 __errno:
46         .word   0
47