comparison lwasm/main.c @ 101:ed7f970f3688

Added --define= option to predfine a symbol for assembly
author lost@l-w.ca
date Sat, 06 Aug 2011 22:15:43 -0600
parents 1f77ae5c3590
children 43a3f1068027
comparison
equal deleted inserted replaced
100:7ce01324e391 101:ed7f970f3688
52 { "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" }, 52 { "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" },
53 { "pragma", 'p', "PRAGMA", 0, "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"}, 53 { "pragma", 'p', "PRAGMA", 0, "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"},
54 { "6809", '9', 0, 0, "Set assembler to 6809 only mode" }, 54 { "6809", '9', 0, 0, "Set assembler to 6809 only mode" },
55 { "6309", '3', 0, 0, "Set assembler to 6309 mode (default)" }, 55 { "6309", '3', 0, 0, "Set assembler to 6309 mode (default)" },
56 { "includedir", 'I', "PATH", 0, "Add entry to include path" }, 56 { "includedir", 'I', "PATH", 0, "Add entry to include path" },
57 { "define", 'D', "SYM[=VAL]", 0, "Automatically define SYM to be VAL (or 1)"},
57 { 0 } 58 { 0 }
58 }; 59 };
59 60
60 61
61 static int parse_opts(int key, char *arg, void *state) 62 static int parse_opts(int key, char *arg, void *state)
65 switch (key) 66 switch (key)
66 { 67 {
67 case 'I': 68 case 'I':
68 lw_stringlist_addstring(as -> include_list, arg); 69 lw_stringlist_addstring(as -> include_list, arg);
69 break; 70 break;
70 71
72 case 'D':
73 {
74 char *offs;
75 int val = 1;
76 lw_expr_t te;
77
78 if ((offs = strchr(arg, '=')))
79 {
80 *offs = '\0';
81 val = strtol(offs + 1, NULL, 0);
82 }
83
84 /* register global symbol */
85 te = lw_expr_build(lw_expr_type_int, val);
86 register_symbol(as, NULL, arg, te, symbol_flag_nocheck | symbol_flag_set);
87 lw_expr_destroy(te);
88
89 if (offs)
90 *offs = '=';
91 break;
92 }
71 case 'o': 93 case 'o':
72 if (as -> output_file) 94 if (as -> output_file)
73 lw_free(as -> output_file); 95 lw_free(as -> output_file);
74 as -> output_file = lw_strdup(arg); 96 as -> output_file = lw_strdup(arg);
75 break; 97 break;