]> Shamusworld >> Repos - rmac/blob - rmac.c
Introducing new switch -fr which outputs binaries assembled at a given address.
[rmac] / rmac.c
1 //
2 // RMAC - Reboot's Macro Assembler for all Atari computers
3 // RMAC.C - Main Application Code
4 // Copyright (C) 199x Landon Dyer, 2011-2020 Reboot and Friends
5 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
6 // Source utilised with the kind permission of Landon Dyer
7 //
8
9 #include "rmac.h"
10 #include "6502.h"
11 #include "debug.h"
12 #include "direct.h"
13 #include "dsp56k.h"
14 #include "error.h"
15 #include "expr.h"
16 #include "listing.h"
17 #include "mark.h"
18 #include "macro.h"
19 #include "object.h"
20 #include "procln.h"
21 #include "riscasm.h"
22 #include "sect.h"
23 #include "symbol.h"
24 #include "token.h"
25 #include "version.h"
26
27 int perm_verb_flag;                             // Permanently verbose, interactive mode
28 int list_flag;                                  // "-l" listing flag on command line
29 int list_pag = 1;                               // Enable listing pagination by default
30 int verb_flag;                                  // Be verbose about what's going on
31 int m6502;                                              // 1, assembling 6502 code
32 int as68_flag;                                  // as68 kludge mode
33 int glob_flag;                                  // Assume undefined symbols are global
34 int lsym_flag;                                  // Include local symbols in object file
35 int sbra_flag;                                  // Warn about possible short branches
36 int prg_flag;                                   // !=0, produce .PRG executable (2=symbols)
37 int prg_extend;                                 // !=0, output extended .PRG symbols
38 int legacy_flag;                                // Do stuff like insert code in RISC assembler
39 int obj_format;                                 // Object format flag
40 int debug;                                              // [1..9] Enable debugging levels
41 int err_flag;                                   // '-e' specified
42 int err_fd;                                             // File to write error messages to
43 int rgpu, rdsp;                                 // Assembling Jaguar GPU or DSP code
44 int robjproc;                                   // Assembling Jaguar Object Processor code
45 int dsp56001;                                   // Assembling DSP 56001 code
46 int list_fd;                                    // File to write listing to
47 int regbank;                                    // RISC register bank
48 int segpadsize;                                 // Segment padding size
49 int endian;                                             // Host processor endianess (0 = LE, 1 = BE)
50 char * objfname;                                // Object filename pointer
51 char * firstfname;                              // First source filename
52 char * cmdlnexec;                               // Executable name, pointer to ARGV[0]
53 char * searchpath;                              // Search path for include files
54 char defname[] = "noname.o";    // Default output filename
55 int optim_flags[OPT_COUNT];             // Specific optimisations on/off matrix
56 int activecpu = CPU_68000;              // Active 68k CPU (68000 by default)
57 int activefpu = FPU_NONE;               // Active FPU (none by default)
58 int org68k_active = 0;                  // .org switch for 68k (only with RAW output format)
59 uint32_t org68k_address;                // .org for 68k
60
61 //
62 // Convert a string to uppercase
63 //
64 void strtoupper(char * s)
65 {
66         while (*s)
67                 *s++ &= 0xDF;
68 }
69
70
71 //
72 // Manipulate file extension.
73 //
74 // 'name' must be large enough to hold any possible filename. If 'stripp' is
75 // nonzero, any old extension is removed. If the file does not already have an
76 // extension, 'extension' is appended to the filename.
77 //
78 char * fext(char * name, char * extension, int stripp)
79 {
80         char * s;
81
82         // Find beginning of "real" name (strip off path)
83         char * beg = strrchr(name, SLASHCHAR);
84
85         if (beg == NULL)
86                 beg = name;
87
88         // Clobber any old extension, if requested
89         if (stripp)
90         {
91                 for(s=beg; *s && *s!='.'; ++s)
92                         ;
93
94                 *s = '\0';
95         }
96
97         if (strrchr(beg, '.') == NULL)
98                 strcat(beg, extension);
99
100         return name;
101 }
102
103
104 //
105 // Return 'item'nth element of semicolon-seperated pathnames specified in the
106 // enviroment string 's'. Copy the pathname to 'buf'.  Return 0 if the 'item'
107 // nth path doesn't exist.
108 //
109 // ['item' ranges from 0 to N-1, where N = #elements in search path]
110 //
111 int nthpath(char * env_var, int itemno, char * buf)
112 {
113         char * s = searchpath;
114
115         if (s == NULL)
116                 s = getenv(env_var);
117
118         if (s == NULL)
119                 return 0;
120
121         while (itemno--)
122                 while (*s != EOS && *s++ != ';')
123                         ;
124
125         if (*s == EOS)
126                 return 0;
127
128         while (*s != EOS && *s != ';')
129                 *buf++ = *s++;
130
131         *buf++ = EOS;
132
133         return 1;
134 }
135
136
137 //
138 // Display command line help
139 //
140 void DisplayHelp(void)
141 {
142         printf("Usage:\n"
143                 "    %s [options] srcfile\n"
144                 "\n"
145                 "Options:\n"
146                 "  -? or -h          Display usage information\n"
147                 "  -dsymbol[=value]  Define symbol (with optional value, default=0)\n"
148                 "  -e[errorfile]     Send error messages to file, not stdout\n"
149                 "  -f[format]        Output object file format\n"
150                 "                    a: ALCYON\n"
151                 "                    b: BSD (use this for Jaguar)\n"
152                 "                    e: ELF\n"
153                 "                    p: P56 (use this for DSP56001 only)\n"
154                 "                    l: LOD (use this for DSP56001 only)\n"
155                 "                    x: com/exe/xex (Atari 800)\n"
156                 "                    r: absolute address"
157                 "  -i[path]          Directory to search for include files\n"
158                 "  -l[filename]      Create an output listing file\n"
159                 "  -l*[filename]     Create an output listing file without pagination\n"
160                 "  -m[cpu]           Select default CPU. Available options:\n"
161                 "                    68000, 68020, 68030, 68040, 68060, 6502, tom, jerry, 56001\n"
162                 "  -n                Don't do things behind your back in RISC assembler\n"
163                 "  -o file           Output file name\n"
164                 "  +o[value]         Turn a specific optimisation on\n"
165                 "                    Available optimisation values and default settings:\n"
166                 "                    o0: Absolute long adddresses to word        (on)\n"
167                 "                    o1: move.l #x,dn/an to moveq                (on)\n"
168                 "                    o2: Word branches to short                  (on)\n"
169                 "                    o3: Outer displacement 0(an) to (an)        (off)\n"
170                 "                    o4: lea size(An),An to addq #size,An        (off)\n"
171                 "                    o5: Absolute long base displacement to word (off)\n"
172                 "                    o6: Null branches to NOP                    (off)\n"
173                 "                    o7: clr.l Dx to moveq #0,Dx                 (off)\n"
174                 "                    o8: adda.w/l #x,Dy to addq.w/l #x,Dy        (off)\n"
175                 "                    o9: adda.w/l #x,Dy to lea x(Dy),Dy          (off)\n"
176                 "  ~o[value]         Turn a specific optimisation off\n"
177                 "  +oall             Turn all optimisations on\n"
178                 "  ~oall             Turn all optimisations off\n"
179                 "  -p                Create an ST .prg (without symbols). Forces -fa\n"
180                 "  -ps               Create an ST .prg (with symbols). Forces -fa\n"
181                 "  -px               Create an ST .prg (with exsymbols). Forces -fa\n"
182                 "  -r[size]          Pad segments to boundary size specified\n"
183                 "                    w: word (2 bytes, default alignment)\n"
184                 "                    l: long (4 bytes)\n"
185                 "                    p: phrase (8 bytes)\n"
186                 "                    d: double phrase (16 bytes)\n"
187                 "                    q: quad phrase (32 bytes)\n"
188                 "  -s                Warn about possible short branches\n"
189                 "                    and applied optimisations\n"
190                 "  -u                Force referenced and undefined symbols global\n"
191                 "  -v                Set verbose mode\n"
192                 "  -x                Turn on debugging mode\n"
193                 "  -y[pagelen]       Set page line length (default: 61)\n"
194                 "\n", cmdlnexec);
195 }
196
197
198 //
199 // Display version information
200 //
201 void DisplayVersion(void)
202 {
203         printf("\n"
204                 " _ __ _ __ ___   __ _  ___ \n"
205                 "| '__| '_ ` _ \\ / _` |/ __|\n"
206                 "| |  | | | | | | (_| | (__ \n"
207                 "|_|  |_| |_| |_|\\__,_|\\___|\n"
208                 "\nReboot's Macro Assembler\n"
209                 "Copyright (C) 199x Landon Dyer, 2011-2020 Reboot\n"
210                 "V%01i.%01i.%01i %s (%s)\n\n", MAJOR, MINOR, PATCH, __DATE__, PLATFORM);
211 }
212
213
214 //
215 // Parse optimisation options
216 //
217 int ParseOptimization(char * optstring)
218 {
219         int onoff = 0;
220
221         if (*optstring == '+')
222                 onoff = 1;
223         else if (*optstring != '~')
224                 return ERROR;
225
226         if ((optstring[2] == 'a' || optstring[2] == 'A')
227                 && (optstring[3] == 'l' || optstring[3] == 'L')
228                 && (optstring[4] == 'l' || optstring[4] == 'L'))
229         {
230                 memset(optim_flags, onoff, OPT_COUNT * sizeof(int));
231                 return OK;
232         }
233         else if (optstring[1] == 'o' || optstring[1] == 'O') // Turn on specific optimisation
234         {
235                 int opt_no = atoi(&optstring[2]);
236
237                 if ((opt_no >= 0) && (opt_no < OPT_COUNT))
238                 {
239                         optim_flags[opt_no] = onoff;
240                         return OK;
241                 }
242                 else
243                         return ERROR;
244         }
245         else
246         {
247                 return ERROR;
248         }
249 }
250
251
252 //
253 // Process command line arguments and do an assembly
254 //
255 int Process(int argc, char ** argv)
256 {
257         int argno;                                              // Argument number
258         SYM * sy;                                               // Pointer to a symbol record
259         char * s;                                               // String pointer
260         int fd;                                                 // File descriptor
261         char fnbuf[FNSIZ];                              // Filename buffer
262         int i;                                                  // Iterator
263
264         errcnt = 0;                                             // Initialize error count
265         listing = 0;                                    // Initialize listing level
266         list_flag = 0;                                  // Initialize listing flag
267         verb_flag = perm_verb_flag;             // Initialize verbose flag
268         as68_flag = 0;                                  // Initialize as68 kludge mode
269         glob_flag = 0;                                  // Initialize .globl flag
270         sbra_flag = 0;                                  // Initialize short branch flag
271         debug = 0;                                              // Initialize debug flag
272         searchpath = NULL;                              // Initialize search path
273         objfname = NULL;                                // Initialize object filename
274         list_fname = NULL;                              // Initialize listing filename
275         err_fname = NULL;                               // Initialize error filename
276         obj_format = BSD;                               // Initialize object format
277         firstfname = NULL;                              // Initialize first filename
278         err_fd = ERROUT;                                // Initialize error file descriptor
279         err_flag = 0;                                   // Initialize error flag
280         rgpu = 0;                                               // Initialize GPU assembly flag
281         rdsp = 0;                                               // Initialize DSP assembly flag
282         robjproc = 0;                                   // Initialize OP assembly flag
283         lsym_flag = 1;                                  // Include local symbols in object file
284         regbank = BANK_N;                               // No RISC register bank specified
285         orgactive = 0;                                  // Not in RISC org section
286         orgwarning = 0;                                 // No ORG warning issued
287         segpadsize = 2;                                 // Initialize segment padding size
288     dsp_orgmap[0].start = 0;            // Initialize 56001 org initial address
289     dsp_orgmap[0].memtype = ORG_P;      // Initialize 56001 org start segment
290         m6502 = 0;                                              // 6502 mode off by default
291
292         // Initialize modules
293         InitSymbolTable();                              // Symbol table
294         InitTokenizer();                                // Tokenizer
295         InitLineProcessor();                    // Line processor
296         InitExpression();                               // Expression analyzer
297         InitSection();                                  // Section manager / code generator
298         InitMark();                                             // Mark tape-recorder
299         InitMacro();                                    // Macro processor
300         InitListing();                                  // Listing generator
301         Init6502();                                             // 6502 assembler
302
303         // Process command line arguments and assemble source files
304         for(argno=0; argno<argc; argno++)
305         {
306                 if (*argv[argno] == '-')
307                 {
308                         switch (argv[argno][1])
309                         {
310                         case 'd':                               // Define symbol
311                         case 'D':
312                                 for(s=argv[argno]+2; *s!=EOS;)
313                                 {
314                                         if (*s++ == '=')
315                                         {
316                                                 s[-1] = EOS;
317                                                 break;
318                                         }
319                                 }
320
321                                 if (argv[argno][2] == EOS)
322                                 {
323                                         printf("-d: empty symbol\n");
324                                         errcnt++;
325                                         return errcnt;
326                                 }
327
328                                 sy = lookup(argv[argno] + 2, 0, 0);
329
330                                 if (sy == NULL)
331                                 {
332                                         sy = NewSymbol(argv[argno] + 2, LABEL, 0);
333                                         sy->svalue = 0;
334                                 }
335
336                                 sy->sattr = DEFINED | EQUATED | ABS;
337                                 sy->svalue = (*s ? (uint64_t)atoi(s) : 0);
338                                 break;
339                         case 'e':                               // Redirect error message output
340                         case 'E':
341                                 err_fname = argv[argno] + 2;
342                                 break;
343                         case 'f':                               // -f<format>
344                         case 'F':
345                                 switch (argv[argno][2])
346                                 {
347                                 case EOS:
348                                 case 'a':                       // -fa = Alcyon [the default]
349                                 case 'A':
350                                         obj_format = ALCYON;
351                                         break;
352                                 case 'b':                       // -fb = BSD (Jaguar Recommended: 3 out 4 jaguars recommend it!)
353                                 case 'B':
354                                         obj_format = BSD;
355                                         break;
356                                 case 'e':                       // -fe = ELF
357                                 case 'E':
358                                         obj_format = ELF;
359                                         break;
360                 case 'l':           // -fl = LOD
361                 case 'L':
362                     obj_format = LOD;
363                     break;
364                 case 'p':           // -fp = P56
365                 case 'P':
366                     obj_format = P56;
367                                         break;
368                                 case 'x':                       // -fx = COM/EXE/XEX
369                                 case 'X':
370                                         obj_format = XEX;
371                                         break;
372                 case 'r':           // -fr = Absolute address
373                 case 'R':
374                     obj_format = RAW;
375                     break;
376                                 default:
377                                         printf("-f: unknown object format specified\n");
378                                         errcnt++;
379                                         return errcnt;
380                                 }
381                                 break;
382                         case 'g':                               // Debugging flag
383                         case 'G':
384                                 printf("Debugging flag (-g) not yet implemented\n");
385                                 break;
386                         case 'i':                               // Set directory search path
387                         case 'I':
388                                 searchpath = argv[argno] + 2;
389                                 break;
390                         case 'l':                               // Produce listing file
391                         case 'L':
392                                 if (*(argv[argno] + 2) == '*')
393                                 {
394                                         list_fname = argv[argno] + 3;
395                                         list_pag = 0;    // Special case - turn off pagination
396                                 }
397                                 else
398                                 {
399                                         list_fname = argv[argno] + 2;
400                                 }
401
402                                 listing = 1;
403                                 list_flag = 1;
404                                 lnsave++;
405                                 break;
406                         case 'm':
407                         case 'M':
408                                 if (strcmp(argv[argno] + 2, "68000") == 0)
409                                         d_68000();
410                                 else if (strcmp(argv[argno] + 2, "68020") == 0)
411                                         d_68020();
412                                 else if (strcmp(argv[argno] + 2, "68030") == 0)
413                                         d_68030();
414                                 else if (strcmp(argv[argno] + 2, "68040") == 0)
415                                         d_68040();
416                                 else if (strcmp(argv[argno] + 2, "68060") == 0)
417                                         d_68060();
418                                 else if (strcmp(argv[argno] + 2, "68881") == 0)
419                                         d_68881();
420                                 else if (strcmp(argv[argno] + 2, "68882") == 0)
421                                         d_68882();
422                                 else if (strcmp(argv[argno] + 2, "56001") == 0)
423                                         d_56001();
424                                 else if (strcmp(argv[argno] + 2, "6502") == 0)
425                                         d_6502();
426                                 else if (strcmp(argv[argno] + 2, "tom") == 0)
427                                         d_gpu();
428                                 else if (strcmp(argv[argno] + 2, "jerry") == 0)
429                                         d_dsp();
430                                 else
431                                 {
432                                         printf("Unrecognized CPU '%s'\n", argv[argno] + 2);
433                                         errcnt++;
434                                         return errcnt;
435                                 }
436                                 break;
437                         case 'o':                               // Direct object file output
438                         case 'O':
439                                 if (argv[argno][2] != EOS)
440                                         objfname = argv[argno] + 2;
441                                 else
442                                 {
443                                         if (++argno >= argc)
444                                         {
445                                                 printf("Missing argument to -o");
446                                                 errcnt++;
447                                                 return errcnt;
448                                         }
449
450                                         objfname = argv[argno];
451                                 }
452
453                                 break;
454                         case 'p':               /* -p: generate ".PRG" executable output */
455                         case 'P':
456                                 /*
457                                  * -p           .PRG generation w/o symbols
458                                  * -ps          .PRG generation with symbols
459                                  * -px          .PRG generation with extended symbols
460                                  */
461                                 switch (argv[argno][2])
462                                 {
463                                         case EOS:
464                                                 prg_flag = 1;
465                                                 break;
466
467                                         case 's':
468                                         case 'S':
469                                                 prg_flag = 2;
470                                                 break;
471
472                                         case 'x':
473                                         case 'X':
474                                                 prg_flag = 3;
475                                                 break;
476
477                                         default:
478                                                 printf("-p: syntax error\n");
479                                                 errcnt++;
480                                                 return errcnt;
481                                 }
482
483                                 // Enforce Alcyon object format - kind of silly
484                                 // to ask for .prg output without it!
485                                 obj_format = ALCYON;
486                                 break;
487                         case 'r':                               // Pad seg to requested boundary size
488                         case 'R':
489                                 switch(argv[argno][2])
490                                 {
491                                 case 'w': case 'W': segpadsize = 2;  break;
492                                 case 'l': case 'L': segpadsize = 4;  break;
493                                 case 'p': case 'P': segpadsize = 8;  break;
494                                 case 'd': case 'D': segpadsize = 16; break;
495                                 case 'q': case 'Q': segpadsize = 32; break;
496                                 default: segpadsize = 2; break; // Effective autoeven();
497                                 }
498                                 break;
499                         case 's':                               // Warn about possible short branches
500                         case 'S':
501                                 sbra_flag = 1;
502                                 break;
503                         case 'u':                               // Make undefined symbols .globl
504                         case 'U':
505                                 glob_flag = 1;
506                                 break;
507                         case 'v':                               // Verbose flag
508                         case 'V':
509                                 verb_flag++;
510
511                                 if (verb_flag > 1)
512                                         DisplayVersion();
513
514                                 break;
515                         case 'x':                               // Turn on debugging
516                         case 'X':
517                                 debug = 1;
518                                 printf("~ Debugging ON\n");
519                                 break;
520                         case 'y':                               // -y<pagelen>
521                         case 'Y':
522                                 pagelen = atoi(argv[argno] + 2);
523
524                                 if (pagelen < 10)
525                                 {
526                                         printf("-y: bad page length\n");
527                                         errcnt++;
528                                         return errcnt;
529                                 }
530
531                                 break;
532                         case EOS:                               // Input is stdin
533                                 if (firstfname == NULL) // Kludge first filename
534                                         firstfname = defname;
535
536                                 include(0, "(stdin)");
537                                 Assemble();
538                                 break;
539                         case 'h':                               // Display command line usage
540                         case 'H':
541                         case '?':
542                                 DisplayVersion();
543                                 DisplayHelp();
544                                 errcnt++;
545                                 break;
546                         case 'n':                               // Turn off legacy mode
547                         case 'N':
548                                 legacy_flag = 0;
549                                 printf("Legacy mode OFF\n");
550                                 break;
551                         default:
552                                 DisplayVersion();
553                                 printf("Unknown switch: %s\n\n", argv[argno]);
554                                 DisplayHelp();
555                                 errcnt++;
556                                 break;
557                         }
558                 }
559                 else if (*argv[argno] == '+' || *argv[argno] == '~')
560                 {
561                         if (ParseOptimization(argv[argno]) != OK)
562                         {
563                                 DisplayVersion();
564                                 printf("Unknown switch: %s\n\n", argv[argno]);
565                                 DisplayHelp();
566                                 errcnt++;
567                                 break;
568                         }
569                 }
570                 else
571                 {
572                         // Record first filename.
573                         if (firstfname == NULL)
574                                 firstfname = argv[argno];
575
576                         strcpy(fnbuf, argv[argno]);
577                         fext(fnbuf, ".s", 0);
578                         fd = open(fnbuf, 0);
579
580                         if (fd < 0)
581                         {
582                                 printf("Cannot open: %s\n", fnbuf);
583                                 errcnt++;
584                                 continue;
585                         }
586
587                         include(fd, fnbuf);
588                         Assemble();
589                 }
590         }
591
592         // Wind-up processing;
593         // o  save current section (no more code generation)
594         // o  do auto-even of all sections (or boundary alignment as requested
595         //    through '-r')
596     // o  save the last pc value for 6502 (if we used 6502 at all) and
597     //    detemine if the last section contains anything
598         // o  determine name of object file:
599         //    -  "foo.o" for linkable output;
600         //    -  "foo.prg" for GEMDOS executable (-p flag).
601         SaveSection();
602         int temp_section = cursect;
603
604         for(i=TEXT; i<=BSS; i<<=1)
605         {
606                 SwitchSection(i);
607
608                 switch(segpadsize)
609                 {
610                 case 2:  d_even();    break;
611                 case 4:  d_long();    break;
612                 case 8:  d_phrase();  break;
613                 case 16: d_dphrase(); break;
614                 case 32: d_qphrase(); break;
615                 }
616
617                 SaveSection();
618         }
619
620         SwitchSection(M6502);
621
622         if (sloc != currentorg[0])
623         {
624                 currentorg[1] = sloc;
625                 currentorg += 2;
626         }
627
628         // This looks like an awful kludge...  !!! FIX !!!
629         if (temp_section & (M56001P | M56001X | M56001Y))
630         {
631                 SwitchSection(temp_section);
632
633                 if (chptr != dsp_currentorg->start)
634                 {
635                         dsp_currentorg->end = chptr;
636                         dsp_currentorg++;
637                 }
638         }
639
640         SwitchSection(TEXT);
641
642         if (objfname == NULL)
643         {
644                 if (firstfname == NULL)
645                         firstfname = defname;
646
647                 strcpy(fnbuf, firstfname);
648                 fext(fnbuf, (prg_flag ? ".prg" : ".o"), 1);
649                 objfname = fnbuf;
650         }
651
652         // With one pass finished, go back and:
653         // (1)   run through all the fixups and resolve forward references;
654         // (1.5) ensure that remaining fixups can be handled by the linker
655         //       (`lo68' format, extended (postfix) format....)
656         // (2)   generate the output file image and symbol table;
657         // (3)   generate relocation information from left-over fixups.
658         ResolveAllFixups();                                             // Do all fixups
659         StopMark();                                                             // Stop mark tape-recorder
660
661         if (errcnt == 0)
662         {
663                 if ((fd = open(objfname, _OPEN_FLAGS, _PERM_MODE)) < 0)
664                         CantCreateFile(objfname);
665
666                 if (verb_flag)
667                 {
668                         s = (prg_flag ? "executable" : "object");
669                         printf("[Writing %s file: %s]\n", s, objfname);
670                 }
671
672                 WriteObject(fd);
673                 close(fd);
674
675                 if (errcnt != 0)
676                         unlink(objfname);
677         }
678
679         if (list_flag)
680         {
681                 if (verb_flag)
682                         printf("[Wrapping-up listing file]\n");
683
684                 listing = 1;
685                 symtable();
686                 close(list_fd);
687         }
688
689         if (err_flag)
690                 close(err_fd);
691
692         DEBUG dump_everything();
693
694         return errcnt;
695 }
696
697
698 //
699 // Determine processor endianess
700 //
701 int GetEndianess(void)
702 {
703         int i = 1;
704         char * p = (char *)&i;
705
706         if (p[0] == 1)
707                 return 0;
708
709         return 1;
710 }
711
712
713 //
714 // Application entry point
715 //
716 int main(int argc, char ** argv)
717 {
718         perm_verb_flag = 0;                             // Clobber "permanent" verbose flag
719         legacy_flag = 1;                                // Default is legacy mode on (:-P)
720
721         // Set legacy optimisation flags to on and everything else to off
722         memset(optim_flags, 0, OPT_COUNT * sizeof(int));
723         optim_flags[OPT_ABS_SHORT] =
724                 optim_flags[OPT_MOVEL_MOVEQ] =
725                 optim_flags[OPT_BSR_BCC_S] = 1;
726
727         cmdlnexec = argv[0];                    // Obtain executable name
728         endian = GetEndianess();                // Get processor endianess
729
730         // If commands were passed in, process them
731         if (argc > 1)
732                 return Process(argc - 1, argv + 1);
733
734         DisplayVersion();
735         DisplayHelp();
736
737         return 0;
738 }
739