]> git.sur5r.net Git - cc65/commitdiff
Added _stroserror
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 18 Jul 2002 13:29:04 +0000 (13:29 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 18 Jul 2002 13:29:04 +0000 (13:29 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@1365 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/cbm/Makefile
libsrc/cbm/oserrlist.s [new file with mode: 0644]
libsrc/common/Makefile
libsrc/common/stroserr.s [new file with mode: 0644]

index 316f06da541587031c6afdb17053a3ebeff703e5..54e6c6314750f62a3c12c278b057ff66347e9ed0 100644 (file)
@@ -47,6 +47,7 @@ S_OBJS =      c_acptr.o       \
                gotox.o         \
                gotoxy.o        \
                gotoy.o         \
+                oserrlist.o     \
                oserror.o       \
                revers.o        \
                where.o
diff --git a/libsrc/cbm/oserrlist.s b/libsrc/cbm/oserrlist.s
new file mode 100644 (file)
index 0000000..2180a7b
--- /dev/null
@@ -0,0 +1,85 @@
+;
+; Ullrich von Bassewitz, 18.07.2002
+;
+; Defines the platform specific error list.
+;
+; The table is built as a list of entries
+;
+;       .byte   entrylen
+;       .byte   errorcode
+;       .asciiz errormsg
+;
+; and terminated by an entry with length zero that is returned if the
+; error code could not be found.
+;
+
+        .export         __sys_oserrlist
+
+;----------------------------------------------------------------------------
+; Macros used to generate the list (may get moved to an include file?)
+
+; Regular entry
+.macro  sys_oserr_entry         code, msg
+        .local  Start, End
+Start:  .byte   End - Start
+        .byte   code
+        .asciiz msg
+End:
+.endmacro
+
+; Sentinel entry
+.macro  sys_oserr_sentinel      msg
+        .byte   0                       ; Length is always zero
+        .byte   0                       ; Code is unused
+        .asciiz msg
+.endmacro
+
+;----------------------------------------------------------------------------
+; The error message table
+
+.rodata
+
+__sys_oserrlist:
+        sys_oserr_entry          1, "Too many open files"
+               sys_oserr_entry          2, "File is open"
+               sys_oserr_entry          3, "File not open"
+               sys_oserr_entry          4, "File not found"
+               sys_oserr_entry          5, "Device not present"
+               sys_oserr_entry          6, "File not input"
+               sys_oserr_entry          7, "File not output"
+               sys_oserr_entry          8, "Filename missing"
+               sys_oserr_entry          9, "Ilegal device"
+               sys_oserr_entry         20, "Read error"
+               sys_oserr_entry         21, "Read error"
+               sys_oserr_entry         22, "Read error"
+               sys_oserr_entry         23, "Read error"
+               sys_oserr_entry         24, "Read error"
+               sys_oserr_entry         25, "Write error"
+               sys_oserr_entry         26, "Write protect on"
+               sys_oserr_entry         27, "Read error"
+               sys_oserr_entry         28, "Write error"
+               sys_oserr_entry         29, "Disk ID mismatch"
+               sys_oserr_entry         30, "Syntax error"
+               sys_oserr_entry         31, "Syntax error"
+               sys_oserr_entry         32, "Syntax error"
+               sys_oserr_entry         33, "Syntax error (invalid file name)"
+               sys_oserr_entry         34, "Syntax error (no file given)"
+               sys_oserr_entry         39, "Syntax error"
+               sys_oserr_entry         50, "Record not present"
+               sys_oserr_entry         51, "Overflow in record"
+               sys_oserr_entry         52, "File too large"
+               sys_oserr_entry         60, "Write file open"
+               sys_oserr_entry         61, "File not open"
+               sys_oserr_entry         62, "File not found"
+               sys_oserr_entry         63, "File exists"
+               sys_oserr_entry         64, "File type mismatch"
+               sys_oserr_entry         65, "No block"
+               sys_oserr_entry         66, "Illegal track or sector"
+               sys_oserr_entry         67, "Illegal system track or sector"
+               sys_oserr_entry         70, "No channel"
+               sys_oserr_entry         71, "Directory error"
+               sys_oserr_entry         72, "Disk full"
+               sys_oserr_entry         73, "DOS version mismatch"
+        sys_oserr_sentinel      "Unknown error"
+
+
index 93d51ec7a95daee363c48df7861c2211d1825814..3fe6083fd79ceeb27b804b2d3b3ba8805c6eb3ab 100644 (file)
@@ -108,6 +108,7 @@ S_OBJS =    _fdesc.o        \
                strncat.o       \
                strncmp.o       \
                strncpy.o       \
+                stroserr.o      \
                strpbrk.o       \
                strrchr.o       \
                strspn.o        \
diff --git a/libsrc/common/stroserr.s b/libsrc/common/stroserr.s
new file mode 100644 (file)
index 0000000..c410b54
--- /dev/null
@@ -0,0 +1,61 @@
+;
+; Ullrich von Bassewitz, 17.07.2002
+;
+; const char* __fastcall__ _stroserror (unsigned char errcode);
+; /* Map an operating system error number to an error message. */
+;
+
+       .export         __stroserror
+       .import         __sys_oserrlist
+        .importzp       ptr1, tmp1
+
+        .macpack        generic
+
+
+; The table is built as a list of entries
+;
+;       .byte   entrylen
+;       .byte   errorcode
+;       .asciiz errormsg
+;
+; and terminated by an entry with length zero that is returned if the
+; error code could not be found.
+
+__stroserror:
+        sta     tmp1                    ; Save the error code
+
+        ldy     #<__sys_oserrlist
+        sty     ptr1
+        ldy     #>__sys_oserrlist
+        sty     ptr1+1                  ; Setup pointer to message table
+
+@L1:    ldy     #0
+        lda     (ptr1),y                ; Get the length
+        beq     Done                    ; Bail out if end of list reached
+
+        iny
+        lda     (ptr1),y                ; Compare the error code
+        cmp     tmp1
+        beq     Done                    ; Jump if found
+
+; Not found, move pointer to next entry
+
+        dey
+        clc
+        lda     ptr1
+        adc     (ptr1),y
+        sta     ptr1
+        bcc     @L1
+        inc     ptr1+1
+        bcs     @L1                     ; Branch always
+
+; We've found the code or reached the end of the list
+
+Done:   ldx     ptr1+1
+        lda     ptr1
+        add     #2                      ; Add a total of #2
+        bcc     @L1
+        inx                             ; Bump high byte
+@L1:    rts
+
+