]> git.sur5r.net Git - cc65/blobdiff - src/cc65/main.c
Allow any number of optional braces around all initializers as required by the standard
[cc65] / src / cc65 / main.c
index 1974aed3d08aee1d464aaf8681adfcb4ac4953b4..19fb4db413c812b3d8473a40996fecfbdcb472bc 100644 (file)
 #include "abend.h"
 #include "chartype.h"
 #include "cmdline.h"
+#include "debugflag.h"
 #include "fname.h"
 #include "print.h"
+#include "segnames.h"
 #include "target.h"
 #include "tgttrans.h"
 #include "version.h"
@@ -91,6 +93,7 @@ static void Usage (void)
                     "  -h\t\t\tHelp (this text)\n"
                     "  -j\t\t\tDefault characters are signed\n"
                     "  -o name\t\tName the output file\n"
+             "  -r\t\t\tEnable register variables\n"
                     "  -t sys\t\tSet the target system\n"
                     "  -v\t\t\tIncrease verbosity\n"
             "\n"
@@ -112,6 +115,8 @@ static void Usage (void)
             "  --help\t\tHelp (this text)\n"
                     "  --include-dir dir\tSet an include directory search path\n"
             "  --list-opt-steps\tList all optimizer steps and exit\n"
+             "  --register-space b\tSet space available for register variables\n"
+             "  --register-vars\tEnable register variables\n"
                     "  --rodata-name seg\tSet the name of the RODATA segment\n"
                     "  --signed-chars\tDefault characters are signed\n"
                     "  --static-locals\tMake local variables static\n"
@@ -148,10 +153,18 @@ static void SetSys (const char* Sys)
            DefineNumericMacro ("__ATARI__", 1);
            break;
 
+       case TGT_C16:
+           cbmsys ("__C16__");
+           break;
+
        case TGT_C64:
            cbmsys ("__C64__");
            break;
 
+       case TGT_VIC20:
+           cbmsys ("__VIC20__");
+           break;
+
        case TGT_C128:
            cbmsys ("__C128__");
            break;
@@ -193,6 +206,10 @@ static void SetSys (const char* Sys)
            DefineNumericMacro ("__LUNIX__", 1);
            break;
 
+        case TGT_ATMOS:
+            DefineNumericMacro ("__ATMOS__", 1);
+            break;
+
        default:
                    AbEnd ("Unknown target system type");
     }
@@ -385,16 +402,16 @@ static void OptDataName (const char* Opt attribute ((unused)), const char* Arg)
 
 
 static void OptDebug (const char* Opt attribute ((unused)),
-                     const char* Arg attribute ((unused)))
+                     const char* Arg attribute ((unused)))
 /* Compiler debug mode */
 {
-    Debug = 1;
+    ++Debug;
 }
 
 
 
 static void OptDebugInfo (const char* Opt attribute ((unused)),
-                         const char* Arg attribute ((unused)))
+                         const char* Arg attribute ((unused)))
 /* Add debug info to the object file */
 {
     DebugInfo = 1;
@@ -516,6 +533,26 @@ static void OptListOptSteps (const char* Opt attribute ((unused)),
 
 
 
+static void OptRegisterSpace (const char* Opt, const char* Arg)
+/* Handle the --register-space option */
+{
+    /* Numeric argument expected */
+    if (sscanf (Arg, "%u", &RegisterSpace) != 1 || RegisterSpace > 256) {
+               AbEnd ("Argument for option %s is invalid", Opt);
+    }
+}
+
+
+
+static void OptRegisterVars (const char* Opt attribute ((unused)),
+                             const char* Arg attribute ((unused)))
+/* Handle the --register-vars option */
+{
+    EnableRegVars = 1;
+}
+
+
+
 static void OptRodataName (const char* Opt attribute ((unused)), const char* Arg)
 /* Handle the --rodata-name option */
 {
@@ -595,10 +632,12 @@ int main (int argc, char* argv[])
        { "--help",             0,      OptHelp                 },
        { "--include-dir",      1,      OptIncludeDir           },
        { "--list-opt-steps",   0,      OptListOptSteps         },
+        { "--register-space",   1,      OptRegisterSpace        },
+        { "--register-vars",    0,      OptRegisterVars         },
        { "--rodata-name",      1,      OptRodataName           },
        { "--signed-chars",     0,      OptSignedChars          },
                { "--static-locals",    0,      OptStaticLocals         },
-       { "--target",           1,      OptTarget               },
+       { "--target",           1,      OptTarget               },
        { "--verbose",          0,      OptVerbose              },
        { "--version",          0,      OptVersion              },
     };
@@ -654,6 +693,10 @@ int main (int argc, char* argv[])
                    OutputFile = GetArg (&I, 2);
                    break;
 
+                case 'r':
+                    OptRegisterVars (Arg, 0);
+                    break;
+
                case 't':
                    OptTarget (Arg, GetArg (&I, 2));
                    break;
@@ -678,8 +721,8 @@ int main (int argc, char* argv[])
                                OptStaticLocals (Arg, 0);
                                break;
                            default:
-                               UnknownOption (Arg);
-                               break;
+                               UnknownOption (Arg);
+                               break;
                        }
                    }
                    break;