* src/pic16/device.c (pic16_dump_usection): force udata sections
[fw/sdcc] / src / z80 / main.c
index 55e9cd51621ff4329e2ef7732169e73f5cd0ec62..fcdd870d47fda52e5a1421132087dcb6a718c6b0 100644 (file)
 #include "SDCCargs.h"
 #include "dbuf_string.h"
 
-#define OPTION_BO             "-bo"
-#define OPTION_BA             "-ba"
-#define OPTION_CODE_SEG       "--codeseg"
-#define OPTION_CONST_SEG      "--constseg"
-#define OPTION_CALLE_SAVES_BC "--calle-saves-bc"
-#define OPTION_PORTMODE       "--portmode="
-#define OPTION_ASM            "--asm="
+#define OPTION_BO              "-bo"
+#define OPTION_BA              "-ba"
+#define OPTION_CODE_SEG        "--codeseg"
+#define OPTION_CONST_SEG       "--constseg"
+#define OPTION_CALLEE_SAVES_BC "--callee-saves-bc"
+#define OPTION_PORTMODE        "--portmode="
+#define OPTION_ASM             "--asm="
+#define OPTION_NO_STD_CRT0     "--no-std-crt0"
 
 
 static char _z80_defaultRules[] =
@@ -55,21 +56,23 @@ Z80_OPTS z80_opts;
 
 static OPTION _z80_options[] =
   {
-    { 0, OPTION_CALLE_SAVES_BC, &z80_opts.calleeSavesBC, "Force a called function to always save BC" },
-    { 0, OPTION_PORTMODE,       NULL,                    "Determine PORT I/O mode (z80/z180)" },
-    { 0, OPTION_ASM,            NULL,                    "Define assembler name (rgbds/asxxxx/isas/z80asm)" },
-    { 0, OPTION_CODE_SEG,       NULL,                    "<name> use this name for the code segment" },
-    { 0, OPTION_CONST_SEG,      NULL,                    "<name> use this name for the const segment" },
+    { 0, OPTION_CALLEE_SAVES_BC, &z80_opts.calleeSavesBC, "Force a called function to always save BC" },
+    { 0, OPTION_PORTMODE,        NULL, "Determine PORT I/O mode (z80/z180)" },
+    { 0, OPTION_ASM,             NULL, "Define assembler name (rgbds/asxxxx/isas/z80asm)" },
+    { 0, OPTION_CODE_SEG,        &options.code_seg, "<name> use this name for the code segment", CLAT_STRING },
+    { 0, OPTION_CONST_SEG,       &options.const_seg, "<name> use this name for the const segment", CLAT_STRING },
+    { 0, OPTION_NO_STD_CRT0,     &options.no_std_crt0, "For the z80/gbz80 do not link default crt0.o"},
     { 0, NULL }
   };
 
 static OPTION _gbz80_options[] = 
   {
-    { 0, OPTION_BO,             NULL,                    "<num> use code bank <num>" },
-    { 0, OPTION_BA,             NULL,                    "<num> use data bank <num>" },
-    { 0, OPTION_CALLE_SAVES_BC, &z80_opts.calleeSavesBC, "Force a called function to always save BC" },
-    { 0, OPTION_CODE_SEG,       NULL,                    "<name> use this name for the code segment"  },
-    { 0, OPTION_CONST_SEG,      NULL,                    "<name> use this name for the const segment" },
+    { 0, OPTION_BO,              NULL, "<num> use code bank <num>" },
+    { 0, OPTION_BA,              NULL, "<num> use data bank <num>" },
+    { 0, OPTION_CALLEE_SAVES_BC, &z80_opts.calleeSavesBC, "Force a called function to always save BC" },
+    { 0, OPTION_CODE_SEG,        &options.code_seg, "<name> use this name for the code segment", CLAT_STRING },
+    { 0, OPTION_CONST_SEG,       &options.const_seg, "<name> use this name for the const segment", CLAT_STRING },
+    { 0, OPTION_NO_STD_CRT0,     &options.no_std_crt0, "For the z80/gbz80 do not link default crt0.o"},
     { 0, NULL }
   };
 
@@ -413,9 +416,9 @@ _parseOptions (int *pargc, char **argv, int *i)
         }
       else if (!strncmp (argv[*i], OPTION_ASM, sizeof (OPTION_ASM) - 1))
         {
-          char *asm = getStringArg (OPTION_ASM, argv, i, *pargc);
+          char *asmblr = getStringArg (OPTION_ASM, argv, i, *pargc);
 
-          if (!strcmp (asm, "rgbds"))
+          if (!strcmp (asmblr, "rgbds"))
             {
               asm_addTree (&_rgbds_gb);
               gbz80_port.assembler.cmd = _gbz80_rgbasmCmd;
@@ -424,12 +427,12 @@ _parseOptions (int *pargc, char **argv, int *i)
               _G.asmType = ASM_TYPE_RGBDS;
               return TRUE;
             }
-          else if (!strcmp (asm, "asxxxx"))
+          else if (!strcmp (asmblr, "asxxxx"))
             {
               _G.asmType = ASM_TYPE_ASXXXX;
               return TRUE;
             }
-          else if (!strcmp (asm, "isas"))
+          else if (!strcmp (asmblr, "isas"))
             {
               asm_addTree (&_isas_gb);
               /* Munge the function prefix */
@@ -437,7 +440,7 @@ _parseOptions (int *pargc, char **argv, int *i)
               _G.asmType = ASM_TYPE_ISAS;
               return TRUE;
             }
-          else if (!strcmp (asm, "z80asm"))
+          else if (!strcmp (asmblr, "z80asm"))
             {
               port->assembler.externGlobal = TRUE;
               asm_addTree (&_z80asm_z80);
@@ -460,18 +463,6 @@ _parseOptions (int *pargc, char **argv, int *i)
               return TRUE;
             }
         }
-      else if (!strcmp (argv[*i], OPTION_CODE_SEG))
-        {
-          if (options.code_seg) Safe_free(options.code_seg);
-          options.code_seg = Safe_strdup(getStringArg (OPTION_CODE_SEG, argv, i, *pargc));
-          return TRUE;
-        }
-      else if (!strcmp (argv[*i], OPTION_CONST_SEG))
-        {
-          if (options.const_seg) Safe_free(options.const_seg);
-          options.const_seg = Safe_strdup(getStringArg (OPTION_CONST_SEG, argv, i, *pargc));
-          return TRUE;
-        }
   }
   return FALSE;
 }
@@ -535,7 +526,7 @@ _setValues(void)
 
   if (IS_GB)
     {
-      setMainValue ("z80outputtypeflag", "-z");
+      setMainValue ("z80outputtypeflag", "-Z");
       setMainValue ("z80outext", ".gb");
     }
   else
@@ -723,23 +714,28 @@ PORT z80_port =
     MODEL_MEDIUM | MODEL_SMALL,
     MODEL_SMALL
   },
-  {
+  {                             /* Assembler */
     NULL,
     ASMCMD,
-    "-plosgff",                 /* Options with debug */
+    "-plosgffc",                /* Options with debug */
     "-plosgff",                 /* Options without debug */
     0,
     ".asm"
   },
-  {
+  {                             /* Linker */
     NULL,
     LINKCMD,
     NULL,
     ".o",
     1
   },
-  {
-    _z80_defaultRules
+  {                             /* Peephole optimizer */
+    _z80_defaultRules,
+    0,
+    0,
+    0,
+    0,
+    z80notUsed
   },
   {
         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
@@ -847,7 +843,7 @@ PORT gbz80_port =
   {
     NULL,
     ASMCMD,
-    "-plosgff",                 /* Options with debug */
+    "-plosgffc",                /* Options with debug */
     "-plosgff",                 /* Options without debug */
     0,
     ".asm",