* src/avr/ralloc.c (serialRegAssign),
[fw/sdcc] / src / z80 / main.c
index cbf52a6d58176c9e839fad27191b2fd278f2d38c..de057f8994a202d70c3ab694776bbfae137210df 100644 (file)
@@ -46,7 +46,13 @@ Z80_OPTS z80_opts;
 static OPTION _z80_options[] = 
   {
     {  0,   "--callee-saves-bc", &z80_opts.calleeSavesBC, "Force a called function to always save BC" },
-    { 80,   "--portmode",        &z80_opts.port_mode,     "Determine PORT I/O mode (z80/z180)" },
+    {  0,   "--portmode=",       NULL,                    "Determine PORT I/O mode (z80/z180)" },
+    {  0, NULL }
+  };
+
+static OPTION _gbz80_options[] = 
+  {
+    {  0,   "--callee-saves-bc", &z80_opts.calleeSavesBC, "Force a called function to always save BC" },
     {  0, NULL }
   };
 
@@ -133,10 +139,15 @@ _reg_parm (sym_link * l)
 static int
 _process_pragma (const char *sz)
 {
-  if( startsWith( sz, "bank=" ))
+  if( startsWith( sz, "bank=" ) || startsWith( sz, "bank " ))
   {
     char buffer[128];
-    strcpy (buffer, sz + 5);
+    
+    if (sz[4]=='=')
+      werror(W_DEPRECATED_PRAGMA, "bank=");
+    
+    strncpy (buffer, sz + 5, sizeof (buffer));
+    buffer[sizeof (buffer) - 1 ] = '\0';
     chomp (buffer);
     if (isdigit (buffer[0]))
     {
@@ -151,7 +162,8 @@ _process_pragma (const char *sz)
          /* Arg was a bank number.  Handle in an ASM independent
             way. */
       char num[128];
-      strcpy (num, sz + 5);
+      strncpy (num, sz + 5, sizeof (num));
+      num[sizeof (num) -1] = '\0';
       chomp (num);
 
       switch (_G.asmType)
@@ -174,11 +186,15 @@ _process_pragma (const char *sz)
     code->sname = gbz80_port.mem.code_name;
     return 0;
   }
-  else if( startsWith( sz, "portmode=" ))
+  else if( startsWith( sz, "portmode=" ) || startsWith( sz, "portmode " ))
   { /*.p.t.20030716 - adding pragma to manipulate z80 i/o port addressing modes */
     char bfr[128];
 
-    strcpy( bfr, sz + 9 );
+    if (sz[8]=='=')
+      werror(W_DEPRECATED_PRAGMA, "portmode=");
+
+    strncpy( bfr, sz + 9, sizeof (bfr));
+    bfr[sizeof (bfr) - 1] = '\0';
     chomp( bfr );
 
     if     ( !strcmp( bfr, "z80"     )){ z80_opts.port_mode =  80; }
@@ -294,6 +310,19 @@ _parseOptions (int *pargc, char **argv, int *i)
              return TRUE;
            }
        }
+      else if (!strncmp (argv[*i], "--portmode=", 11))
+       {
+         if (!strcmp (argv[*i], "--portmode=z80"))
+           {
+             z80_opts.port_mode =  80;
+             return TRUE;
+           }
+         else if (!strcmp (argv[*i], "--portmode=z180"))
+           {
+             z80_opts.port_mode =  180;
+             return TRUE;
+           }
+        }
     }
   return FALSE;
 }
@@ -594,10 +623,14 @@ PORT z80_port =
   {
     0, 2
   },
+  {
+    z80_emitDebuggerSymbol
+  },
   "_",
   _z80_init,
   _parseOptions,
   _z80_options,
+  NULL,
   _finaliseOptions,
   _setDefaultOptions,
   z80_assignRegisters,
@@ -607,6 +640,7 @@ PORT z80_port =
   NULL,                                /* no genAssemblerEnd */
   0,                           /* no local IVT generation code */
   0,                            /* no genXINIT code */
+  NULL,                        /* genInitStartup */
   _reset_regparm,
   _reg_parm,
   _process_pragma,
@@ -694,10 +728,14 @@ PORT gbz80_port =
   {
     0, 2
   },
+  {
+    z80_emitDebuggerSymbol
+  },
   "_",
   _gbz80_init,
   _parseOptions,
-  _z80_options,
+  _gbz80_options,
+  NULL,
   _finaliseOptions,
   _setDefaultOptions,
   z80_assignRegisters,
@@ -707,6 +745,7 @@ PORT gbz80_port =
   NULL,                                /* no genAssemblerEnd */
   0,                           /* no local IVT generation code */
   0,                            /* no genXINIT code */
+  NULL,                        /* genInitStartup */
   _reset_regparm,
   _reg_parm,
   _process_pragma,