comparison lwdisasm/main.c @ 409:cba03436c720

Checkpoint disassembler
author lost@l-w.ca
date Mon, 02 Aug 2010 18:07:04 -0600
parents 2a94b2e64621
children
comparison
equal deleted inserted replaced
408:2a94b2e64621 409:cba03436c720
74 { 74 {
75 fprintf(stderr, "Invalid range: %s\n", arg); 75 fprintf(stderr, "Invalid range: %s\n", arg);
76 exit(1); 76 exit(1);
77 } 77 }
78 // register the range as data 78 // register the range as data
79 register_range(as, rangelow, rangehigh, type_data);
79 break; 80 break;
80 81
81 case 0x102: // code range 82 case 0x102: // code range
82 rangelow = strtol(arg, &e, 0); 83 rangelow = strtol(arg, &e, 0);
83 if (*e != ':') 84 if (*e != ':')
90 { 91 {
91 fprintf(stderr, "Invalid range: %s\n", arg); 92 fprintf(stderr, "Invalid range: %s\n", arg);
92 exit(1); 93 exit(1);
93 } 94 }
94 // register the range as code 95 // register the range as code
96 register_range(as, rangelow, rangehigh, type_code);
95 break; 97 break;
96 98
97 case 0x103: // entry 99 case 0x103: // entry
98 as -> entry = strtol(arg, NULL, 0); 100 as -> entry = strtol(arg, NULL, 0);
99 break; 101 break;
180 /* 182 /*
181 main function; parse command line, set up disassembler state, and run the 183 main function; parse command line, set up disassembler state, and run the
182 disassembler on the first file 184 disassembler on the first file
183 */ 185 */
184 186
187 void do_disasm_raw(disasmstate_t *as);
188
185 int main(int argc, char **argv) 189 int main(int argc, char **argv)
186 { 190 {
187 disasmstate_t as = { 0 }; 191 disasmstate_t as = { 0 };
188 FILE *fp; 192 FILE *fp;
189 193
213 as.filedata = lw_alloc(as.filelen); 217 as.filedata = lw_alloc(as.filelen);
214 0 == fread(as.filedata, as.filelen, 1, fp); 218 0 == fread(as.filedata, as.filelen, 1, fp);
215 219
216 fclose(fp); 220 fclose(fp);
217 221
222 switch (as.target)
223 {
224 case TARGET_6309:
225 as.page0 = page0_6309;
226 as.page1 = page1_6309;
227 as.page2 = page2_6309;
228 break;
229
230 case TARGET_6809:
231 as.page0 = page0_6809;
232 as.page1 = page1_6809;
233 as.page2 = page2_6809;
234 break;
235
236 default:
237 as.page0 = page0_6809;
238 as.page1 = page1_6809;
239 as.page2 = page2_6809;
240 break;
241
242 }
243
244 switch (as.input_type)
245 {
246 case INPUT_RAW:
247 do_disasm_raw(&as);
248 break;
249
250 default:
251 fprintf(stderr, "Input type is not currently implemented\n");
252 exit(1);
253 }
254
218 exit(0); 255 exit(0);
219 } 256 }