Mercurial > hg > index.cgi
comparison lwasm/main.c @ 390:1ebb5a0b2874
Add option to specify tab width in listing
There is much insistence that generating the asm listing should absolutely
not ever in the entire expanse of space and time expand tabs. lwasm,
however, does so, and it does so for a reason. That reason is that there are
enough users that have enough trouble even understanding what a tab is that
it was simpler to just expand them.
That said, having a means to actually specify the tab width is pretty much
required if you're going to do that, and having a way to disable such
expansion is also a good idea.
Thanks to Erik G <erik@6809.org> for the base patch to handle this.
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 13 Jul 2015 21:52:43 -0600 |
parents | 71f507f404f1 |
children | 4411a6123716 |
comparison
equal
deleted
inserted
replaced
389:2d9b7ae6c329 | 390:1ebb5a0b2874 |
---|---|
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, raw, obj, os9"}, | 47 { "format", 'f', "TYPE", 0, "Select output format: decb, raw, obj, os9"}, |
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 { "symbols", 's', 0, lw_cmdline_opt_optional, "Generate symbol list in listing, no effect without --list"}, | 49 { "symbols", 's', 0, lw_cmdline_opt_optional, "Generate symbol list in listing, no effect without --list"}, |
50 { "symbols-nolocals", 0x103, 0, lw_cmdline_opt_optional, "Same as --symbols but with local labels ignored"}, | 50 { "symbols-nolocals", 0x103, 0, lw_cmdline_opt_optional, "Same as --symbols but with local labels ignored"}, |
51 { "tabs", 't', "WIDTH", 0, "Set tab spacing in listing (0=don't expand tabs)" }, | |
51 { "map", 'm', "FILE", lw_cmdline_opt_optional, "Generate map [to FILE]"}, | 52 { "map", 'm', "FILE", lw_cmdline_opt_optional, "Generate map [to FILE]"}, |
52 { "decb", 'b', 0, 0, "Generate DECB .bin format output, equivalent of --format=decb"}, | 53 { "decb", 'b', 0, 0, "Generate DECB .bin format output, equivalent of --format=decb"}, |
53 { "raw", 'r', 0, 0, "Generate raw binary format output, equivalent of --format=raw"}, | 54 { "raw", 'r', 0, 0, "Generate raw binary format output, equivalent of --format=raw"}, |
54 { "obj", 0x100, 0, 0, "Generate proprietary object file format for later linking, equivalent of --format=obj" }, | 55 { "obj", 0x100, 0, 0, "Generate proprietary object file format for later linking, equivalent of --format=obj" }, |
55 { "depend", 0x101, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual" }, | 56 { "depend", 0x101, 0, 0, "Output a dependency list to stdout; do not do any actual output though assembly is completed as usual" }, |
56 { "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" }, | 57 { "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" }, |
57 { "pragma", 'p', "PRAGMA", 0, "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"}, | 58 { "pragma", 'p', "PRAGMA", 0, "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"}, |
58 { "6809", '9', 0, 0, "Set assembler to 6809 only mode" }, | 59 { "6809", '9', 0, 0, "Set assembler to 6809 only mode" }, |
59 { "6309", '3', 0, 0, "Set assembler to 6309 mode (default)" }, | 60 { "6309", '3', 0, 0, "Set assembler to 6309 mode (default)" }, |
60 { "includedir", 'I', "PATH", 0, "Add entry to include path" }, | 61 { "includedir", 'I', "PATH", 0, "Add entry to include path" }, |
61 { "define", 'D', "SYM[=VAL]", 0, "Automatically define SYM to be VAL (or 1)"}, | 62 { "define", 'D', "SYM[=VAL]",0, "Automatically define SYM to be VAL (or 1)"}, |
62 { "preprocess", 'P', 0, 0, "Preprocess macros and conditionals and output revised source to stdout" }, | 63 { "preprocess", 'P', 0, 0, "Preprocess macros and conditionals and output revised source to stdout" }, |
63 { "unicorns", 0x142, 0, 0, "Add sooper sekrit sauce"}, | 64 { "unicorns", 0x142, 0, 0, "Add sooper sekrit sauce"}, |
64 { "6800compat", 0x200, 0, 0, "Enable 6800 compatibility instructions, equivalent to --pragma=6800compat" }, | 65 { "6800compat", 0x200, 0, 0, "Enable 6800 compatibility instructions, equivalent to --pragma=6800compat" }, |
65 { 0 } | 66 { 0 } |
66 }; | 67 }; |
110 if (!arg) | 111 if (!arg) |
111 as -> debug_level = 50; | 112 as -> debug_level = 50; |
112 else | 113 else |
113 as -> debug_level = atoi(arg); | 114 as -> debug_level = atoi(arg); |
114 #endif | 115 #endif |
116 break; | |
117 | |
118 case 't': | |
119 if (arg) | |
120 as -> tabwidth = atoi(arg); | |
115 break; | 121 break; |
116 | 122 |
117 case 'l': | 123 case 'l': |
118 if (as -> list_file) | 124 if (as -> list_file) |
119 lw_free(as -> list_file); | 125 lw_free(as -> list_file); |
291 /* initialize assembler state */ | 297 /* initialize assembler state */ |
292 asmstate.include_list = lw_stringlist_create(); | 298 asmstate.include_list = lw_stringlist_create(); |
293 asmstate.input_files = lw_stringlist_create(); | 299 asmstate.input_files = lw_stringlist_create(); |
294 asmstate.nextcontext = 1; | 300 asmstate.nextcontext = 1; |
295 asmstate.exprwidth = 16; | 301 asmstate.exprwidth = 16; |
302 asmstate.tabwidth = 8; | |
296 | 303 |
297 /* parse command line arguments */ | 304 /* parse command line arguments */ |
298 lw_cmdline_parse(&cmdline_parser, argc, argv, 0, 0, &asmstate); | 305 lw_cmdline_parse(&cmdline_parser, argc, argv, 0, 0, &asmstate); |
299 | 306 |
300 if (!asmstate.output_file) | 307 if (!asmstate.output_file) |