]> git.sur5r.net Git - cc65/blob - libsrc/cbm/oserror.s
Merge remote-tracking branch 'upstream/master'
[cc65] / libsrc / cbm / oserror.s
1 ;
2 ; Ullrich von Bassewitz, 17.05.2000
3 ;
4 ; int __fastcall__ _osmaperrno (unsigned char oserror);
5 ; /* Map a system specific error into a system independent code */
6 ;
7
8         .include        "errno.inc"
9
10 .code
11
12 __osmaperrno:
13         ldx     #ErrTabSize
14 @L1:    cmp     ErrTab-2,x      ; Search for the error code
15         beq     @L2             ; Jump if found
16         dex
17         dex
18         bne     @L1             ; Next entry
19
20 ; Code not found, return EUNKNOWN
21
22         lda     #<EUNKNOWN
23         ldx     #>EUNKNOWN
24         rts
25
26 ; Found the code
27
28 @L2:    lda     ErrTab-1,x
29         ldx     #$00            ; High byte always zero
30         rts
31
32 .rodata
33
34 ErrTab:
35         .byte   1, EMFILE       ; Too many open files
36         .byte   2, EINVAL       ; File is open
37         .byte   3, EINVAL       ; File not open
38         .byte   4, ENOENT       ; File not found
39         .byte   5, ENODEV       ; Device not present
40         .byte   6, EINVAL       ; File not input
41         .byte   7, EINVAL       ; File not output
42         .byte   8, EINVAL       ; Filename missing
43         .byte   9, ENODEV       ; Ilegal device
44 ;       .byte  20,              ; Read error
45 ;       .byte  21,              ; Read error
46 ;       .byte  22,              ; Read error
47 ;       .byte  23,              ; Read error
48 ;       .byte  24,              ; Read error
49 ;       .byte  25,              ; Write error
50         .byte  26, EACCES       ; Write protect on
51 ;       .byte  27,              ; Read error
52 ;       .byte  28,              ; Write error
53 ;       .byte  29,              ; Disk ID mismatch
54 ;       .byte  30,              ; Syntax error
55 ;       .byte  31,              ; Syntax error
56 ;       .byte  32,              ; Syntax error
57         .byte  33, EINVAL       ; Syntax error (invalid file name)
58         .byte  34, EINVAL       ; Syntax error (no file given)
59 ;       .byte  39,              ; Syntax error
60 ;       .byte  50,              ; Record not present
61 ;       .byte  51,              ; Overflow in record
62 ;       .byte  52,              ; File too large
63         .byte  60, EINVAL       ; Write file open
64         .byte  61, EINVAL       ; File not open
65         .byte  62, ENOENT       ; File not found
66         .byte  63, EEXIST       ; File exists
67         .byte  64, EINVAL       ; File type mismatch
68 ;       .byte  65,              ; No block
69 ;       .byte  66,              ; Illegal track or sector
70 ;       .byte  67,              ; Illegal system track or sector
71         .byte  70, EBUSY        ; No channel
72 ;       .byte  71,              ; Directory error
73 ;       .byte  72,              ; Disk full
74 ;       .byte  73,              ; DOS version mismatch
75         .byte  74, ENODEV       ; Drive not ready
76
77 ErrTabSize = (* - ErrTab)