comparison src/main.c @ 143:0ee5f65bccf9

Added pragma to allow all undefined symbols to be considered external and also added a --pragma command line option
author lost
date Thu, 29 Jan 2009 01:32:11 +0000
parents 36ca3fa755e0
children
comparison
equal deleted inserted replaced
142:36ca3fa755e0 143:0ee5f65bccf9
36 // external declarations 36 // external declarations
37 extern void lwasm_pass1(asmstate_t *as); 37 extern void lwasm_pass1(asmstate_t *as);
38 extern void lwasm_pass2(asmstate_t *as); 38 extern void lwasm_pass2(asmstate_t *as);
39 extern void lwasm_list(asmstate_t *as); 39 extern void lwasm_list(asmstate_t *as);
40 extern void lwasm_output(asmstate_t *as); 40 extern void lwasm_output(asmstate_t *as);
41 extern void pseudo_pragma_real(asmstate_t *as, lwasm_line_t *cl, char **optr, int error);
41 42
42 // command line option handling 43 // command line option handling
43 const char *argp_program_version = "LWASM from " PACKAGE_STRING; 44 const char *argp_program_version = "LWASM from " PACKAGE_STRING;
44 const char *argp_program_bug_address = PACKAGE_BUGREPORT; 45 const char *argp_program_bug_address = PACKAGE_BUGREPORT;
45 46
46 static error_t parse_opts(int key, char *arg, struct argp_state *state) 47 static error_t parse_opts(int key, char *arg, struct argp_state *state)
47 { 48 {
48 asmstate_t *as = state -> input; 49 asmstate_t *as = state -> input;
50 char *p;
49 51
50 switch (key) 52 switch (key)
51 { 53 {
52 case 'o': 54 case 'o':
53 // output 55 // output
97 { 99 {
98 fprintf(stderr, "Invalid output format: %s\n", arg); 100 fprintf(stderr, "Invalid output format: %s\n", arg);
99 exit(1); 101 exit(1);
100 } 102 }
101 break; 103 break;
104
105 case 'p':
106 // pragmas
107 p = arg;
108 pseudo_pragma_real(as, NULL, &p, 2);
109 if (!p)
110 {
111 fprintf(stderr, "Invalid pragma string: %s\n", arg);
112 exit(1);
113 }
114 break;
115
102 case ARGP_KEY_END: 116 case ARGP_KEY_END:
103 // done; sanity check 117 // done; sanity check
104 if (!as -> outfile) 118 if (!as -> outfile)
105 as -> outfile = "a.out"; 119 as -> outfile = "a.out";
106 break; 120 break;
132 "Generate DECB .bin format output, equivalent of --format=decb"}, 146 "Generate DECB .bin format output, equivalent of --format=decb"},
133 { "raw", 'r', 0, 0, 147 { "raw", 'r', 0, 0,
134 "Generate raw binary format output, equivalent of --format=raw"}, 148 "Generate raw binary format output, equivalent of --format=raw"},
135 { "obj", 0x100, 0, 0, 149 { "obj", 0x100, 0, 0,
136 "Generate proprietary object file format for later linking, equivalent of --format=obj" }, 150 "Generate proprietary object file format for later linking, equivalent of --format=obj" },
151 { "pragma", 'p', "PRAGMA", 0,
152 "Set an assembler pragma to any value understood by the \"pragma\" pseudo op"},
137 { 0 } 153 { 0 }
138 }; 154 };
139 155
140 static struct argp argp = 156 static struct argp argp =
141 { 157 {