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