comparison lwasm/main.c @ 543:e10618b48e68

Implement support for dragon format binaries Implement support for dragon format binaries. As an added bonus, also implement a variation on raw binaries which guarantees the whole binary fits in the file. These are the "dragon" and "abs" output formats. Based on code submitted by Mike Miller.
author William Astle <lost@l-w.ca>
date Thu, 29 Sep 2022 13:59:42 -0600
parents 7fbf3171ca15
children ddc7b05a5675
comparison
equal deleted inserted replaced
542:f3018ed5e30e 543:e10618b48e68
42 42
43 static struct lw_cmdline_options options[] = 43 static struct lw_cmdline_options options[] =
44 { 44 {
45 { "output", 'o', "FILE", 0, "Output to FILE"}, 45 { "output", 'o', "FILE", 0, "Output to FILE"},
46 { "debug", 'd', "LEVEL", lw_cmdline_opt_optional, "Set debug mode"}, 46 { "debug", 'd', "LEVEL", lw_cmdline_opt_optional, "Set debug mode"},
47 { "format", 'f', "TYPE", 0, "Select output format: decb, basic, raw, obj, os9, ihex, srec"}, 47 { "format", 'f', "TYPE", 0, "Select output format: decb, basic, raw, obj, os9, ihex, srec, dragon, abs"},
48 { "list", 'l', "FILE", lw_cmdline_opt_optional, "Generate list [to FILE]"}, 48 { "list", 'l', "FILE", lw_cmdline_opt_optional, "Generate list [to FILE]"},
49 { "list-nofiles", 0x104, 0, 0, "Omit file names in list output"}, 49 { "list-nofiles", 0x104, 0, 0, "Omit file names in list output"},
50 { "symbols", 's', 0, lw_cmdline_opt_optional, "Generate symbol list in listing, no effect without --list"}, 50 { "symbols", 's', 0, lw_cmdline_opt_optional, "Generate symbol list in listing, no effect without --list"},
51 { "symbols-nolocals", 0x103, 0, lw_cmdline_opt_optional, "Same as --symbols but with local labels ignored"}, 51 { "symbols-nolocals", 0x103, 0, lw_cmdline_opt_optional, "Same as --symbols but with local labels ignored"},
52 { "symbol-dump", 0x106, "FILE", lw_cmdline_opt_optional, "Dump global symbol table in assembly format" }, 52 { "symbol-dump", 0x106, "FILE", lw_cmdline_opt_optional, "Dump global symbol table in assembly format" },
53 { "tabs", 't', "WIDTH", 0, "Set tab spacing in listing (0=don't expand tabs)" }, 53 { "tabs", 't', "WIDTH", 0, "Set tab spacing in listing (0=don't expand tabs)" },
54 { "map", 'm', "FILE", lw_cmdline_opt_optional, "Generate map [to FILE]"}, 54 { "map", 'm', "FILE", lw_cmdline_opt_optional, "Generate map [to FILE]"},
55 { "decb", 'b', 0, 0, "Generate DECB .bin format output, equivalent of --format=decb"}, 55 { "decb", 'b', 0, 0, "Generate DECB .bin format output, equivalent of --format=decb"},
56 { "dragon", 0x107, 0, 0, "Generate a Dragon DOS binary format, equivalent of --format=dragon"},
57 { "abs", 0x108, 0, 0, "Generate absolute binary format, equivalent of --format=abs"},
56 { "raw", 'r', 0, 0, "Generate raw binary format output, equivalent of --format=raw"}, 58 { "raw", 'r', 0, 0, "Generate raw binary format output, equivalent of --format=raw"},
57 { "obj", 0x100, 0, 0, "Generate proprietary object file format for later linking, equivalent of --format=obj" }, 59 { "obj", 0x100, 0, 0, "Generate proprietary object file format for later linking, equivalent of --format=obj" },
58 { "depend", 0x101, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual" }, 60 { "depend", 0x101, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual" },
59 { "dependnoerr", 0x102, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual; don't bail on missing include files" }, 61 { "dependnoerr", 0x102, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual; don't bail on missing include files" },
60 { "pragma", 'p', "PRAGMA", 0, "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"}, 62 { "pragma", 'p', "PRAGMA", 0, "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"},
170 as -> listnofile = 1; 172 as -> listnofile = 1;
171 break; 173 break;
172 174
173 case 'b': 175 case 'b':
174 as -> output_format = OUTPUT_DECB; 176 as -> output_format = OUTPUT_DECB;
177 break;
178
179 case 0x107:
180 as -> output_format = OUTPUT_DRAGON;
181 break;
182
183 case 0x108:
184 as -> output_format = OUTPUT_ABS;
175 break; 185 break;
176 186
177 case 'r': 187 case 'r':
178 as -> output_format = OUTPUT_RAW; 188 as -> output_format = OUTPUT_RAW;
179 break; 189 break;
209 as -> output_format = OUTPUT_SREC; 219 as -> output_format = OUTPUT_SREC;
210 else if (!strcasecmp(arg, "ihex")) 220 else if (!strcasecmp(arg, "ihex"))
211 as -> output_format = OUTPUT_IHEX; 221 as -> output_format = OUTPUT_IHEX;
212 else if (!strcasecmp(arg, "hex")) 222 else if (!strcasecmp(arg, "hex"))
213 as -> output_format = OUTPUT_HEX; 223 as -> output_format = OUTPUT_HEX;
224 else if (!strcasecmp(arg, "dragon"))
225 as -> output_format = OUTPUT_DRAGON;
226 else if (!strcasecmp(arg, "abs"))
227 as -> output_format = OUTPUT_ABS;
214 else if (!strcasecmp(arg, "os9")) 228 else if (!strcasecmp(arg, "os9"))
215 { 229 {
216 as -> pragmas |= PRAGMA_DOLLARNOTLOCAL; 230 as -> pragmas |= PRAGMA_DOLLARNOTLOCAL;
217 as -> output_format = OUTPUT_OS9; 231 as -> output_format = OUTPUT_OS9;
218 } 232 }