- " -d\t\t\tDebug mode\n"
- " -g\t\t\tAdd debug info to object file\n"
- " -h\t\t\tHelp (this text)\n"
- " -j\t\t\tDefault characters are signed\n"
- " -o name\t\tName the output file\n"
- " -t sys\t\tSet the target system\n"
- " -v\t\t\tIncrease verbosity\n"
" -A\t\t\tStrict ANSI mode\n"
" -Cl\t\t\tMake local variables static\n"
" -Dsym[=defn]\t\tDefine a symbol\n"
" -A\t\t\tStrict ANSI mode\n"
" -Cl\t\t\tMake local variables static\n"
" -Dsym[=defn]\t\tDefine a symbol\n"
" -T\t\t\tInclude source as comment\n"
" -V\t\t\tPrint the compiler version number\n"
" -W\t\t\tSuppress warnings\n"
" -T\t\t\tInclude source as comment\n"
" -V\t\t\tPrint the compiler version number\n"
" -W\t\t\tSuppress warnings\n"
+ " -d\t\t\tDebug mode\n"
+ " -g\t\t\tAdd debug info to object file\n"
+ " -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"
" --ansi\t\tStrict ANSI mode\n"
" --bss-name seg\tSet the name of the BSS segment\n"
" --check-stack\t\tGenerate stack overflow checks\n"
" --code-name seg\tSet the name of the CODE segment\n"
" --codesize x\t\tAccept larger code by factor x\n"
" --ansi\t\tStrict ANSI mode\n"
" --bss-name seg\tSet the name of the BSS segment\n"
" --check-stack\t\tGenerate stack overflow checks\n"
" --code-name seg\tSet the name of the CODE segment\n"
" --codesize x\t\tAccept larger code by factor x\n"
" --data-name seg\tSet the name of the DATA segment\n"
" --debug\t\tDebug mode\n"
" --debug-info\t\tAdd debug info to object file\n"
" --debug-opt name\tDebug optimization steps\n"
" --disable-opt name\tDisable an optimization step\n"
" --enable-opt name\tEnable an optimization step\n"
" --data-name seg\tSet the name of the DATA segment\n"
" --debug\t\tDebug mode\n"
" --debug-info\t\tAdd debug info to object file\n"
" --debug-opt name\tDebug optimization steps\n"
" --disable-opt name\tDisable an optimization step\n"
" --enable-opt name\tEnable an optimization step\n"
- " --list-opt-steps\tList all optimizer steps\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"
" --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"
- AddNumericMacro ("__CBM__", 1);
- AddNumericMacro (sys, 1);
+ DefineNumericMacro ("__CBM__", 1);
+ DefineNumericMacro (sys, 1);
+ case TGT_LUNIX:
+ DefineNumericMacro ("__LUNIX__", 1);
+ break;
+
+ case TGT_ATMOS:
+ DefineNumericMacro ("__ATMOS__", 1);
+ break;
+
+ case TGT_NES:
+ DefineNumericMacro ("__NES__", 1);
+ break;
+
} else {
/* We have a value, P points to the '=' character. Since the argument
* is const, create a copy and replace the '=' in the copy by a zero
} else {
/* We have a value, P points to the '=' character. Since the argument
* is const, create a copy and replace the '=' in the copy by a zero
static void OptCPU (const char* Opt, const char* Arg)
/* Handle the --cpu option */
{
static void OptCPU (const char* Opt, const char* Arg)
/* Handle the --cpu option */
{
- if (strcmp (Arg, "6502") == 0) {
- CPU = CPU_6502;
- } else if (strcmp (Arg, "65C02") == 0) {
- CPU = CPU_65C02;
- } else {
- AbEnd ("Invalid CPU: `%s'", Arg);
+ /* Find the CPU from the given name */
+ CPU = FindCPU (Arg);
+ if (CPU != CPU_6502 && CPU != CPU_65C02) {
+ AbEnd ("Invalid argument for %s: `%s'", Opt, Arg);
-static void OptDataName (const char* Opt, const char* Arg)
-/* Handle the --code-name option */
+static void OptDataName (const char* Opt attribute ((unused)), const char* Arg)
+/* Handle the --data-name option */
-static void OptHelp (const char* Opt, const char* Arg)
+static void OptForgetIncPaths (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Forget all currently defined include paths */
+{
+ ForgetAllIncludePaths ();
+}
+
+
+
+static void OptHelp (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
/* Add an include search path */
{
AddIncludePath (Arg, INC_SYS | INC_USER);
/* Add an include search path */
{
AddIncludePath (Arg, INC_SYS | INC_USER);
+
+ /* Terminate */
+ exit (EXIT_SUCCESS);
+}
+
+
+
+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 OptRodataName (const char* Opt, const char* Arg)
+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)
{ "--check-stack", 0, OptCheckStack },
{ "--code-name", 1, OptCodeName },
{ "--codesize", 1, OptCodeSize },
{ "--check-stack", 0, OptCheckStack },
{ "--code-name", 1, OptCodeName },
{ "--codesize", 1, OptCodeSize },
{ "--data-name", 1, OptDataName },
{ "--debug", 0, OptDebug },
{ "--debug-info", 0, OptDebugInfo },
{ "--debug-opt", 1, OptDebugOpt },
{ "--disable-opt", 1, OptDisableOpt },
{ "--data-name", 1, OptDataName },
{ "--debug", 0, OptDebug },
{ "--debug-info", 0, OptDebugInfo },
{ "--debug-opt", 1, OptDebugOpt },
{ "--disable-opt", 1, OptDisableOpt },
- { "--enable-opt", 1, OptEnableOpt, },
+ { "--enable-opt", 1, OptEnableOpt },
+ { "--forget-inc-paths", 0, OptForgetIncPaths },
{ "--help", 0, OptHelp },
{ "--include-dir", 1, OptIncludeDir },
{ "--list-opt-steps", 0, OptListOptSteps },
{ "--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 },
{ "--rodata-name", 1, OptRodataName },
{ "--signed-chars", 0, OptSignedChars },
{ "--static-locals", 0, OptStaticLocals },
- { "--target", 1, OptTarget },
+ { "--target", 1, OptTarget },
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
};
{ "--verbose", 0, OptVerbose },
{ "--version", 0, OptVersion },
};
+ /* If no CPU given, use the default CPU for the target */
+ if (CPU == CPU_UNKNOWN) {
+ if (Target != TGT_UNKNOWN) {
+ CPU = DefaultCPU[Target];
+ } else {
+ CPU = CPU_6502;
+ }
+ }
+