]> git.sur5r.net Git - cc65/commitdiff
Merge pull request #305 from silverdr/target_goodies
authorOliver Schmidt <ol.sc@web.de>
Wed, 1 Jun 2016 14:44:57 +0000 (16:44 +0200)
committerOliver Schmidt <ol.sc@web.de>
Wed, 1 Jun 2016 14:44:57 +0000 (16:44 +0200)
corrected samples and samples.d64 targets

19 files changed:
asminc/atari.inc
cfg/atari-cassette.cfg
doc/atari.sgml
doc/funcref.sgml
include/atari.h
libsrc/apple2/exec.s
libsrc/atari/dosdetect.s
libsrc/atari/getargs.s
libsrc/atari/getdefdev.s
libsrc/atari/is_cmdline_dos.s [new file with mode: 0644]
libsrc/atari/sysrmdir.s
libsrc/atari/targetutil/w2cas.c
libsrc/vic20/kernal.s
src/cc65/codegen.c
src/cc65/stdfunc.c
src/cc65/stdfunc.h
src/ld65/scanner.c
testcode/lib/atari/defdev.c
testcode/lib/atari/mem.c

index 3cce030467de324d298a17c025e3df16a184ec46..f7a7ab223b853357708bad05db457238c58a43c3 100644 (file)
@@ -106,7 +106,7 @@ SIO_WRPERCOM = $4F      ;write PERCOM block (XF551)
 SIO_WRITE    = $50      ;write sector
 SIO_READ     = $52      ;read sector
 SIO_STAT     = $53      ;get status information
-SIO_VERIFY   = $56      ;verify sector 
+SIO_VERIFY   = $56      ;verify sector
 SIO_WRITEV   = $57      ;write sector with verify
 SIO_WRITETRK = $60      ;write track (Speedy)
 SIO_READTRK  = $62      ;read track (Speedy)
@@ -689,7 +689,7 @@ CASFLG  = $030F         ;CASSETTE MODE WHEN SET
 TIMER2  = $0310         ;2-byte final baud rate timer value
 TEMP1   = $0312         ;TEMPORARY STORAGE REGISTER
 ;TEMP2  = $0314         ;##old## TEMPORARY STORAGE REGISTER
-TEMP2   = $0313         ;##1200xl## 1-byte temporary 
+TEMP2   = $0313         ;##1200xl## 1-byte temporary
 PTIMOT  = $0314         ;##1200xl## 1-byte printer timeout
 TEMP3   = $0315         ;TEMPORARY STORAGE REGISTER
 SAVIO   = $0316         ;SAVE SERIAL IN DATA PORT
@@ -765,7 +765,7 @@ CART    = $BFFC         ;##rev2## 1-byte cartridge present indicator
                         ;0=Cart Exists
 CARTFG  = $BFFD         ;##rev2## 1-byte cartridge flags
                         ;D7  0=Not a Diagnostic Cart
-                        ;    1=Is a Diagnostic cart and control is 
+                        ;    1=Is a Diagnostic cart and control is
                         ;      given to cart before any OS is init.
                         ;D2  0=Init but Do not Start Cart
                         ;    1=Init and Start Cart
@@ -925,7 +925,7 @@ RADON   = 0             ;INDICATES RADIANS
 DEGON   = 6             ;INDICATES DEGREES
 
 ASCZER  = '0'           ;ASCII ZERO
-COLON   = $3A           ;ASCII COLON 
+COLON   = $3A           ;ASCII COLON
 CR      = $9B           ;SYSTEM EOL (CARRIAGE RETURN)
 
 ;-------------------------------------------------------------------------
@@ -997,12 +997,31 @@ diopp_size   = 5        ; size of structure
 ; VALUES for dos_type
 ;-------------------------------------------------------------------------
 
-ATARIDOS     = 0
-SPARTADOS    = 1
-OSADOS       = 2        ; OS/A+
-MYDOS        = 3
-XDOS         = 4
+SPARTADOS    = 0
+OSADOS       = 1        ; OS/A+
+XDOS         = 2
+ATARIDOS     = 3
+MYDOS        = 4
 NODOS        = 255
+; The DOSes with dos_type below or equal MAX_DOS_WITH_CMDLINE do support
+; command line arguments.
+MAX_DOS_WITH_CMDLINE = XDOS
+
+;-------------------------------------------------------------------------
+; XDOS defines (version 2.4, taken from xdos24.pdf)
+;-------------------------------------------------------------------------
+
+XOPT         = $070B    ; XDOS options
+XCAR         = $070C    ; XDOS cartridge address (+ $70D)
+XPAT         = $086F    ; XDOS bugfix and patch number
+XVER         = $0870    ; XDOS version number
+XFILE        = $087D    ; XDOS filename buffer
+XLINE        = $0880    ; XDOS DUP input line
+XGLIN        = $0871    ; get line
+XSKIP        = $0874    ; skip parameter
+XMOVE        = $0877    ; move filename
+XGNUM        = $087A    ; get number
+XDEFDEV      = $0816    ; current drive * undocumented *
 
 ;-------------------------------------------------------------------------
 ; End of atari.inc
index 84bb5ad022bb81d2ae9f974616ba88e135487384..5e99c303e8bcff3c4648142aa66236940a36cec3 100644 (file)
@@ -21,7 +21,7 @@ SEGMENTS {
     CODE:     load = MAIN, type = ro,  define = yes;
     RODATA:   load = MAIN, type = ro,                optional = yes;
     DATA:     load = MAIN, type = rw,                optional = yes;
-    BSS:      load = MAIN, type = bss, define = yes;
+    BSS:      load = MAIN, type = bss, define = yes, optional = yes;
     INIT:     load = MAIN, type = bss,               optional = yes;
 }
 FEATURES {
index cfa1937e03ef8a5362540b79eb88ddf668268255..e65a7869e3d26a766df6f61b9fe49d976fd659d5 100644 (file)
@@ -275,6 +275,7 @@ See the <url url="funcref.html" name="function reference"> for declaration and u
 <item>_getcolor
 <item>_getdefdev
 <item>_graphics
+<item>_is_cmdline_dos
 <item>_rest_vecs
 <item>_save_vecs
 <item>_scroll
index a2ccf6c73c653df3a0ddf395bbafd93085bea59c..9bd4a35957a8515ec6443373387c8cc2110af5af 100644 (file)
@@ -98,6 +98,7 @@ function.
 <!-- <item><ref id="_getcolor" name="_getcolor"> -->
 <!-- <item><ref id="_getdefdev" name="_getdefdev"> -->
 <!-- <item><ref id="_graphics" name="_graphics"> -->
+<item><ref id="_is_cmdline_dos" name="_is_cmdline_dos">
 <!-- <item><ref id="_rest_vecs" name="_rest_vecs"> -->
 <!-- <item><ref id="_save_vecs" name="_save_vecs"> -->
 <!-- <item><ref id="_scroll" name="_scroll"> -->
@@ -939,6 +940,40 @@ id="malloc" name="malloc"> may still return <tt/NULL/.
 </quote>
 
 
+<sect1>_is_cmdline_dos<label id="_is_cmdline_dos"><p>
+
+<quote>
+<descrip>
+<tag/Function/Determines whether the underlying DOS supports command line arguments.
+<tag/Header/<tt/<ref id="atari.h" name="atari.h">/
+<tag/Declaration/<tt/unsigned char _is_cmdline_dos (void);/
+<tag/Description/The function returns 0 if the DOS doesn't support command line arguments.
+It returns 1 if it does.
+<tag/Notes/<itemize>
+<item>Many Atari DOSes which don't support command line arguments immediately clear the screen
+and display their menu after a program exits. Therefore it might be difficult to read
+the last messages printed by the program prior to its exit. This function can be used
+to decide if a delay or wait for a key press should be executed when then program
+exits.
+</itemize>
+<tag/Availability/cc65 (<tt/atari/ and <tt/atarixl/ platforms)
+<tag/Example/<verb>
+/* Hello World for Atari */
+#include <stdio.h>
+#include <unistd.h>
+#include <atari.h>
+int main(void)
+{
+    printf("Hello World\n");
+    if (! _is_cmdline_dos())
+        sleep(5);
+    return 0;
+}
+</verb>
+</descrip>
+</quote>
+
+
 <sect1>_poserror<label id="_poserror"><p>
 
 <quote>
index 82cd07330a0a3be7bf410b0896f0882e57921ea5..fa99fca20d719e1676d725349b73ed20437c3635 100644 (file)
@@ -161,11 +161,12 @@ extern void __fastcall__ _scroll (signed char numlines);
                                           /* numlines < 0  scrolls down */
 
 /* misc. functions */
-extern unsigned char get_ostype(void);  /* get ROM version */
-extern unsigned char get_tv(void);      /* get TV system */
-extern void _save_vecs(void);           /* save system vectors */
-extern void _rest_vecs(void);           /* restore system vectors */
-extern char *_getdefdev(void);          /* get default floppy device */
+extern unsigned char get_ostype(void);       /* get ROM version */
+extern unsigned char get_tv(void);           /* get TV system */
+extern void _save_vecs(void);                /* save system vectors */
+extern void _rest_vecs(void);                /* restore system vectors */
+extern char *_getdefdev(void);               /* get default floppy device */
+extern unsigned char _is_cmdline_dos(void);  /* does DOS support command lines */
 
 /* global variables */
 extern unsigned char _dos_type;         /* the DOS flavour */
@@ -261,11 +262,11 @@ extern void atrx15p2_tgi[];
 #define AT_PAL      1
 
 /* valid _dos_type values */
-#define ATARIDOS    0
-#define SPARTADOS   1
-#define OSADOS      2
-#define MYDOS       3
-#define XDOS        4
+#define SPARTADOS   0
+#define OSADOS      1
+#define XDOS        2
+#define ATARIDOS    3
+#define MYDOS       4
 #define NODOS       255
 
 /* Define hardware */
index d24de604c668bb66d58ce872138ee7ed8f2d52ab..c0cd98650417ff4e92a3fc6a87ebf7ba209e29fe 100644 (file)
@@ -230,14 +230,13 @@ source: jsr     $BF00
         ; Check for startup filename support
         ; ProDOS TechRefMan, chapter 5.1.5.1:
         ; "$2000 is a jump instruction. $2003 and $2004 are $EE."
-system: lda     $2000
-        cmp     #$4C
+system: lda     #$4C
+        cmp     $2000
         bne     jump
-        lda     $2003
-        cmp     #$EE
+        lda     #$EE
+        cmp     $2003
         bne     jump
-        lda     $2004
-        cmp     #$EE
+        cmp     $2004
         bne     jump
 
         ; Store cmdline in startup filename buffer
index c2888d888baae78561c97e5954b95dd97d9071cb..68f4aefb20a1c8d5b06aea4749ee24dd9f36a1fd 100644 (file)
@@ -50,4 +50,4 @@ done:   rts
 
         .data
 
-__dos_type:     .byte   0       ; default to ATARIDOS
+__dos_type:     .byte   ATARIDOS; default to ATARIDOS
index e3b18b2f92270c6f1111f5d5ad813e33d20a10f5..b1b5d258d49c8ef59842704ac5a29bfd6fe5b562 100644 (file)
@@ -7,6 +7,8 @@
 ; startup code but is nevertheless included in the compiled program when
 ; needed.
 
+; XDOS support added 05/2016 by Christian Groessler
+
 MAXARGS = 16            ; max. amount of arguments in arg. table
 CL_SIZE = 64            ; command line buffer size
 SPACE   = 32            ; SPACE char.
@@ -22,22 +24,30 @@ SPACE   = 32            ; SPACE char.
 
 .segment        "ONCE"
 
+nargdos:rts
+
 initmainargs:
         lda     __dos_type      ; which DOS?
-        cmp     #ATARIDOS
-        beq     nargdos         ; DOS does not support arguments
-        cmp     #MYDOS
-        bne     argdos          ; DOS supports arguments
-nargdos:rts
+        cmp     #MAX_DOS_WITH_CMDLINE + 1
+        bcs     nargdos
 
 ; Initialize ourcl buffer
 
-argdos: lda     #ATEOL
-        sta     ourcl+CL_SIZE
+argdos: ldy     #ATEOL
+        sty     ourcl+CL_SIZE
 
-; Move SpartaDOS command line to our own buffer
+; Move SpartaDOS/XDOS command line to our own buffer
+
+        cmp     #XDOS
+        bne     sparta
+
+        lda     #<XLINE
+        sta     ptr1
+        lda     #>XLINE
+        sta     ptr1+1
+        bne     cpcl0
 
-        lda     DOSVEC
+sparta: lda     DOSVEC
         clc
         adc     #<LBUF
         sta     ptr1
@@ -45,7 +55,7 @@ argdos: lda     #ATEOL
         adc     #>LBUF
         sta     ptr1+1
 
-        ldy     #0
+cpcl0:  ldy     #0
 cpcl:   lda     (ptr1),y
         sta     ourcl,y
         iny
index 47d8714e65d0a029524dd77a0bc4e750a2199793..a1c950dc50e9112b9aea3c847adf05385289fb75 100644 (file)
 __getdefdev:
 
         lda     __dos_type      ; which DOS?
-        cmp     #ATARIDOS
-        beq     finish
-        cmp     #MYDOS
-        beq     finish
+        cmp     #XDOS
+        beq     xdos            ; only supported on XDOS ...
+;       cmp     #OSADOS+1       ; (redundant: #OSADOS+1 = #XDOS)
+        bcs     finish          ; ... and on OS/A+ and SpartaDOS
 
         ldy     #BUFOFF
         lda     #0
@@ -60,7 +60,7 @@ __getdefdev:
         lda     (DOSVEC),y
         sta     crvec+2
 
-crvec:  jsr     $FFFF           ; will be set to crunch vector
+        jsr     crvec
 
 ; Get default device
 
@@ -69,7 +69,7 @@ crvec:  jsr     $FFFF           ; will be set to crunch vector
         sta     __defdev
         iny
         lda     (DOSVEC),y
-        sta     __defdev+1
+done:   sta     __defdev+1
 
 ; Return pointer to default device
 
@@ -77,8 +77,15 @@ finish: lda     #<__defdev
         ldx     #>__defdev
         rts
 
+; XDOS version
+
+xdos:   lda     XDEFDEV
+        bne     done
+
         .data
 
+crvec:  jmp     $FFFF           ; target address will be set to crunch vector
+
 ; Default device
 
 __defdev:
diff --git a/libsrc/atari/is_cmdline_dos.s b/libsrc/atari/is_cmdline_dos.s
new file mode 100644 (file)
index 0000000..71b35fb
--- /dev/null
@@ -0,0 +1,20 @@
+;
+; Christian Groessler, May-2016
+;
+; unsigned char _is_cmdline_dos(void);
+;
+; returns 0 for non-commandline DOS, 1 for commandline DOS
+;
+
+        .export  __is_cmdline_dos
+        .import  __dos_type
+        .include "atari.inc"
+
+__is_cmdline_dos:
+        ldx     #0
+        lda     __dos_type
+        cmp     #MAX_DOS_WITH_CMDLINE + 1
+        txa
+        rol     a
+        eor     #$01
+        rts
index 3f5b9e447b25a996a3bca8d1ede782b6612da25d..f568ded6ea0c26278e7b420c8948122859cc4b6c 100644 (file)
 
         pha
         lda     __dos_type
-        beq     not_impl                ; AtariDOS
         cmp     #OSADOS+1
         bcc     do_sparta               ; OS/A and SpartaDOS
+        cmp     #MYDOS
+        bne     not_impl                ; neither MyDOS, OS/A, nor SpartaDOS
         pla
-        jmp     __sysremove             ; MyDOS and others (TODO: check XDOS)
+        jmp     __sysremove             ; MyDOS
 
 not_impl:
         pla
index 4d574da073b9a4f93c8d776907e9b5c0ca2d3e95..c95ff7ba5ca87b6ef72d99af1b5107e8606b6121 100644 (file)
@@ -32,6 +32,13 @@ static struct __iocb *findfreeiocb(void)
     return NULL;
 }
 
+static void exitfn(void)
+{
+    /* if DOS will automatically clear the screen, after the program exits, wait for a keypress... */
+    if (! _is_cmdline_dos())
+        cgetc();
+}
+
 int main(int argc, char **argv)
 {
     char *filename, *x;
@@ -43,10 +50,10 @@ int main(int argc, char **argv)
     struct __iocb *iocb = findfreeiocb();
     int iocb_num;
 
+    atexit(exitfn);
+
     if (! iocb) {
         fprintf(stderr, "couldn't find a free iocb\n");
-        if (_dos_type != 1)
-            cgetc();
         return 1;
     }
     iocb_num = (iocb - &IOCB) * 16;
@@ -57,10 +64,16 @@ int main(int argc, char **argv)
         printf("\nfilename: ");
         x = fgets(buf, 19, stdin);
         printf("\n");
-        if (! x)
+        if (! x) {
+            printf("empty filename, exiting...\n");
             return 1;
+        }
         if (*x && *(x + strlen(x) - 1) == '\n')
             *(x + strlen(x) - 1) = 0;
+        if (! strlen(x)) {  /* empty filename */
+            printf("empty filename, exiting...\n");
+            return 1;
+        }
         filename = x;
     }
     else {
@@ -74,8 +87,6 @@ int main(int argc, char **argv)
         buffer = malloc(buflen);
         if (! buffer) {
             fprintf(stderr, "cannot alloc %ld bytes -- aborting...\n", (long)buflen);
-            if (_dos_type != 1)
-                cgetc();
             return 1;
         }
     }
@@ -87,8 +98,6 @@ int main(int argc, char **argv)
     if (! file) {
         free(buffer);
         fprintf(stderr, "cannot open '%s': %s\n", filename, strerror(errno));
-        if (_dos_type != 1)
-            cgetc();
         return 1;
     }
 
@@ -101,8 +110,6 @@ int main(int argc, char **argv)
     file_err:
         fclose(file);
         free(buffer);
-        if (_dos_type != 1)
-            cgetc();
         return 1;
     }
     if (filen > 32767l) {
@@ -133,8 +140,6 @@ int main(int argc, char **argv)
     if (regs.y != 1) {
         fprintf(stderr, "CIO call to open cassette returned %d\n", regs.y);
         free(buffer);
-        if (_dos_type != 1)
-            cgetc();
         return 1;
     }
 
@@ -157,8 +162,6 @@ int main(int argc, char **argv)
         regs.pc = 0xe456;   /* CIOV */
         _sys(&regs);
 
-        if (_dos_type != 1)
-            cgetc();
         return 1;
     }
 
@@ -173,14 +176,10 @@ int main(int argc, char **argv)
 
     if (regs.y != 1) {
         fprintf(stderr, "CIO call to close cassette returned %d\n", regs.y);
-        if (_dos_type != 1)
-            cgetc();
         return 1;
     }
 
     /* all is fine */
     printf("success\n");
-    if (_dos_type != 1)
-        cgetc();
     return 0;
 }
index 35bedb4661946a2f442016cd77c86cefc7c51fe2..040dbf5e51df086adf38c805c3f6d4f38e4f9e36 100644 (file)
@@ -47,9 +47,9 @@
 ;-----------------------------------------------------------------------------
 ; All functions are available in the kernal jump table
 
-CINT            = $FF81
-IOINIT          = $FF84
-RAMTAS          = $FF87
+CINT            = $E518         ; No entries are in the kernal jump table of the Vic20 for these three (3) functions.
+IOINIT          = $FDF9         ; The entries for these functions have been set to point directly to the functions 
+RAMTAS          = $FD8D         ; in the kernal to maintain compatibility with the other Commodore platforms.
 RESTOR          = $FF8A
 VECTOR          = $FF8D
 SETMSG          = $FF90
index f6ec2f51acdf0aacecdd3d0114509a1807ba5dcf..bf0251813619859df15c110108c12e8c404a87ba 100644 (file)
@@ -55,6 +55,7 @@
 #include "global.h"
 #include "segments.h"
 #include "stackptr.h"
+#include "stdfunc.h"
 #include "textseg.h"
 #include "util.h"
 #include "codegen.h"
@@ -4241,7 +4242,7 @@ void g_initauto (unsigned Label, unsigned Size)
         AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, Label, 0));
         AddCodeLine ("sta (sp),y");
         AddCodeLine ("iny");
-        AddCodeLine ("cpy #$%02X", (unsigned char) Size);
+       AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size);
         AddCodeLine ("bne %s", LocalLabelName (CodeLabel));
     }
 }
@@ -4266,10 +4267,10 @@ void g_initstatic (unsigned InitLabel, unsigned VarLabel, unsigned Size)
         AddCodeLine ("lda %s,y", GetLabelName (CF_STATIC, InitLabel, 0));
         AddCodeLine ("sta %s,y", GetLabelName (CF_STATIC, VarLabel, 0));
         AddCodeLine ("iny");
-        AddCodeLine ("cpy #$%02X", (unsigned char) Size);
+       AddCmpCodeIfSizeNot256 ("cpy #$%02X", Size);
         AddCodeLine ("bne %s", LocalLabelName (CodeLabel));
     } else {
-        /* Use the easy way here: memcpy */
+        /* Use the easy way here: memcpy() */
         g_getimmed (CF_STATIC, VarLabel, 0);
         AddCodeLine ("jsr pushax");
         g_getimmed (CF_STATIC, InitLabel, 0);
index 182cad1ef40da99a27fb80bae390ee928ba37cf7..720e6db15fdcac43c8980c31b1734067726c7685 100644 (file)
@@ -185,6 +185,19 @@ static void ParseArg (ArgDesc* Arg, Type* Type)
 
 
 
+void AddCmpCodeIfSizeNot256 (const char* Code, long Size)
+/* Add a line of Assembly code that compares an index register
+** only if it isn't comparing to #<256.  (If the next line
+** is "bne", then this will avoid a redundant line.)
+*/
+{
+    if (Size != 256) {
+        AddCodeLine (Code, (unsigned int)Size);
+    }
+}
+
+
+
 /*****************************************************************************/
 /*                                  memcpy                                   */
 /*****************************************************************************/
@@ -272,7 +285,6 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
         if (Arg3.Expr.IVal <= 127) {
 
             AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
-            AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
             g_defcodelabel (Label);
             if (Reg2) {
                 AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0));
@@ -290,7 +302,6 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
         } else {
 
             AddCodeLine ("ldy #$00");
-            AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
             g_defcodelabel (Label);
             if (Reg2) {
                 AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0));
@@ -303,7 +314,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
                 AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
             }
             AddCodeLine ("iny");
-            AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
+            AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
             AddCodeLine ("bne %s", LocalLabelName (Label));
 
         }
@@ -366,7 +377,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
                 AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs));
                 AddCodeLine ("sta (sp),y");
                 AddCodeLine ("iny");
-                AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal));
+                AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
                 AddCodeLine ("bne %s", LocalLabelName (Label));
             } else {
                 AddCodeLine ("ldx #$00");
@@ -376,7 +387,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
                 AddCodeLine ("sta (sp),y");
                 AddCodeLine ("iny");
                 AddCodeLine ("inx");
-                AddCodeLine ("cpx #$%02X", (unsigned char) Arg3.Expr.IVal);
+                AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal);
                 AddCodeLine ("bne %s", LocalLabelName (Label));
             }
 
@@ -440,7 +451,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
                 AddCodeLine ("lda (sp),y");
                 AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs));
                 AddCodeLine ("iny");
-                AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal));
+                AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
                 AddCodeLine ("bne %s", LocalLabelName (Label));
             } else {
                 AddCodeLine ("ldx #$00");
@@ -450,7 +461,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
                 AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0));
                 AddCodeLine ("iny");
                 AddCodeLine ("inx");
-                AddCodeLine ("cpx #$%02X", (unsigned char) Arg3.Expr.IVal);
+                AddCmpCodeIfSizeNot256 ("cpx #$%02X", Arg3.Expr.IVal);
                 AddCodeLine ("bne %s", LocalLabelName (Label));
             }
 
@@ -487,7 +498,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
             AddCodeLine ("lda (sp),y");
             AddCodeLine ("sta (ptr1),y");
             AddCodeLine ("iny");
-            AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
+            AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
             AddCodeLine ("bne %s", LocalLabelName (Label));
         }
 
@@ -631,7 +642,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
                 AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
             }
             AddCodeLine ("iny");
-            AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
+            AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
             AddCodeLine ("bne %s", LocalLabelName (Label));
 
         }
@@ -661,7 +672,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
         g_defcodelabel (Label);
         AddCodeLine ("sta (sp),y");
         AddCodeLine ("iny");
-        AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal));
+        AddCmpCodeIfSizeNot256 ("cpy #$%02X", Offs + Arg3.Expr.IVal);
         AddCodeLine ("bne %s", LocalLabelName (Label));
 
         /* memset returns the address, so the result is actually identical
@@ -697,7 +708,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
             g_defcodelabel (Label);
             AddCodeLine ("sta (ptr1),y");
             AddCodeLine ("iny");
-            AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
+            AddCmpCodeIfSizeNot256 ("cpy #$%02X", Arg3.Expr.IVal);
             AddCodeLine ("bne %s", LocalLabelName (Label));
         }
 
index 7fc3abd3ecc7f0b20e3ef11a030088f6980231fb..e944d70b973b1ccba1ced41358282b448586166f 100644 (file)
 
 
 
+void AddCmpCodeIfSizeNot256 (const char* Code, long Size);
+/* Add a line of Assembly code that compares an index register
+** only if it isn't comparing to #<256.  (If the next line
+** is "bne", then this will avoid a redundant line.)
+*/
+
 int FindStdFunc (const char* Name);
 /* Determine if the given function is a known standard function that may be
 ** called in a special way. If so, return the index, otherwise return -1.
@@ -61,5 +67,4 @@ void HandleStdFunc (int Index, struct FuncDesc* F, ExprDesc* lval);
 
 
 /* End of stdfunc.h */
-
 #endif
index 0f6ea58de4240b2090abfc916f2dcb70aaf38ba4..3c2346aac9973cef83921fc9392430856589bd5e 100644 (file)
@@ -505,7 +505,7 @@ void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name)
     }
 
     /* Not found or no identifier */
-    CfgError (&CfgErrorPos, "%s expected", Name);
+    CfgError (&CfgErrorPos, "%s expected, got '%s'", Name, SB_GetConstBuf(&CfgSVal));
 }
 
 
index f679985ec536ac7e2cef18c7bd7f3eb9b9862052..06ddb6365564cab02c07b42679a84dbb5e791fbf 100644 (file)
@@ -13,6 +13,6 @@ extern char _defdev[];
 int main(void)
 {
         printf("default device: %s\n", _defdev);
-        if (_dos_type != SPARTADOS && _dos_type != OSADOS) cgetc();
+        if (! _is_cmdline_dos()) cgetc();
         return 0;
 }
index 36222e08b2e321f1bf35e482510252d906eeb6f2..a8d50cf30923e34db58ddd8003f7c59506e835da 100644 (file)
@@ -11,7 +11,6 @@
 
 extern int getsp(void);                         /* comes from ../getsp.s */
 
-extern char _dos_type;                          /* bss variable */
 unsigned char data = 0x12;                      /* data variable */
 
 unsigned int *APPMHI = (unsigned int *)14;      /* 14,15 */
@@ -42,6 +41,6 @@ int main(void)
   printf("  sp:              $%04X  (stack ptr)\n", getsp());
 
   if (allocmem) free(allocmem);
-  if (_dos_type != 1) cgetc();
+  if (! _is_cmdline_dos()) cgetc();
   return(0);
 }