+//
+// Parse optimisation options
+//
+int ParseOptimization(char * optstring)
+{
+ int onoff = 0;
+
+ while (*optstring)
+ {
+ if (*optstring == '+')
+ onoff = 1;
+ else if (*optstring != '~')
+ return ERROR;
+
+ if (optstring[2] == 0)
+ return error(".opt called with zero arguments");
+
+ if ((optstring[2] == 'a' || optstring[2] == 'A')
+ && (optstring[3] == 'l' || optstring[3] == 'L')
+ && (optstring[4] == 'l' || optstring[4] == 'L'))
+ {
+ memset(optim_flags, onoff, OPT_COUNT * sizeof(int));
+ optstring += 5;
+ }
+ else if (optstring[1] == 'o' || optstring[1] == 'O') // Turn on specific optimisation
+ {
+ if (optstring[2] == 'p' || optstring[2] == 'P')
+ {
+ optim_flags[OPT_PC_RELATIVE] = onoff;
+ optstring += 3;
+ }
+ else
+ {
+ int opt_no = atoi(&optstring[2]);
+
+ if ((opt_no >= 0) && (opt_no < OPT_COUNT))
+ {
+ optim_flags[opt_no] = onoff;
+ optstring += 3;
+
+ // If opt_no is 2 digits then consume an extra character.
+ // Sounds a bit sleazy but we know we're not going to hit
+ // more than 100 optimisation switches so this should be
+ // fine. If we do hit that number then it'll probably be
+ // time to burn the whole codebase and start from scratch.
+ if (opt_no > 9)
+ optstring++;
+ }
+ else
+ return ERROR;
+ }
+ }
+ else
+ {
+ return ERROR;
+ }
+
+ if (*optstring == ',')
+ optstring++;
+ }
+ return OK;
+}
+
+static void ProcessFile(int fd, char *fname)
+{
+ char *dbgname = fname;
+
+ if (NULL == fname)
+ {
+ fname = defname; // Kludge first filename
+ dbgname = "(stdin)";
+ }
+
+ // First file operations:
+ if (firstfname == NULL)
+ {
+ // Record first filename.
+ firstfname = fname;
+
+ // Validate option compatibility
+ if (dsym_flag)
+ {
+ if (obj_format != BSD)
+ {
+ printf("-g: debug information only supported with BSD object file format\n");
+ dsym_flag = 0;
+ errcnt++;
+ }
+ else
+ {
+ GenMainFileSym(dbgname);
+ }
+ }
+ }
+
+ include(fd, dbgname);
+ Assemble();
+}
+
+extern int reg68base[53];
+extern int reg68tab[222];
+extern int reg68check[222];
+extern int reg68accept[222];