comparison lwasm/lwasm.h @ 376:35d4213e6657

Add cycle counting to listing Add option to include instruction cycle counts to the listing. Thanks to Erik G <erik@6809.org> for the patch.
author William Astle <lost@l-w.ca>
date Mon, 13 Jul 2015 20:47:30 -0600
parents 71f507f404f1
children 67373a053c49
comparison
equal deleted inserted replaced
375:71f507f404f1 376:35d4213e6657
91 PRAGMA_SYMBOLNOCASE = 1 << 10, // symbols defined under this pragma are matched case insensitively 91 PRAGMA_SYMBOLNOCASE = 1 << 10, // symbols defined under this pragma are matched case insensitively
92 PRAGMA_CONDUNDEFZERO = 1 << 11, // treat undefined symbols as zero in conditionals during pass 1 92 PRAGMA_CONDUNDEFZERO = 1 << 11, // treat undefined symbols as zero in conditionals during pass 1
93 PRAGMA_6800COMPAT = 1 << 12, // enable 6800 compatibility opcodes 93 PRAGMA_6800COMPAT = 1 << 12, // enable 6800 compatibility opcodes
94 PRAGMA_FORWARDREFMAX = 1 << 13, // force incomplete references on pass 1 to maximum mode 94 PRAGMA_FORWARDREFMAX = 1 << 13, // force incomplete references on pass 1 to maximum mode
95 PRAGMA_6809 = 1 << 14, // 6809/6309 assembly mode 95 PRAGMA_6809 = 1 << 14, // 6809/6309 assembly mode
96 PRAGMA_TESTMODE = 1 << 15 // enable test mode (for internal unit testing) 96 PRAGMA_TESTMODE = 1 << 15, // enable test mode (for internal unit testing)
97 PRAGMA_C = 1 << 16, // enable cycle counts
98 PRAGMA_CD = 1 << 17, // enable detailed cycle count
99 PRAGMA_CT = 1 << 18, // enable cycle count running total
100 PRAGMA_CC = 1 << 19 // clear cycle count running total
97 }; 101 };
98 102
99 enum 103 enum
100 { 104 {
101 section_flag_bss = 1, // BSS section 105 section_flag_bss = 1, // BSS section
230 { 234 {
231 char *symbol; // symbol to import 235 char *symbol; // symbol to import
232 importlist_t *next; // next in the import list 236 importlist_t *next; // next in the import list
233 }; 237 };
234 238
239 typedef enum
240 {
241 CYCLE_ADJ = 1,
242 CYCLE_ESTIMATED = 2
243 } cycle_flags;
244
235 struct line_s 245 struct line_s
236 { 246 {
237 lw_expr_t addr; // assembly address of the line 247 lw_expr_t addr; // assembly address of the line
238 lw_expr_t daddr; // data address of the line (os9 only) 248 lw_expr_t daddr; // data address of the line (os9 only)
239 int len; // the "size" this line occupies (address space wise) (-1 if unknown) 249 int len; // the "size" this line occupies (address space wise) (-1 if unknown)
245 char *sym; // symbol, if any, on the line 255 char *sym; // symbol, if any, on the line
246 unsigned char *output; // output bytes 256 unsigned char *output; // output bytes
247 int outputl; // size of output 257 int outputl; // size of output
248 int outputbl; // size of output buffer 258 int outputbl; // size of output buffer
249 int dpval; // direct page value 259 int dpval; // direct page value
260 int cycle_base; // base instruction cycle count
261 int cycle_adj; // cycle adjustment
262 int cycle_flags; // cycle flags
250 lwasm_error_t *err; // list of errors 263 lwasm_error_t *err; // list of errors
251 lwasm_error_t *warn; // list of errors 264 lwasm_error_t *warn; // list of errors
252 lwasm_errorcode_t err_testmode; // error code in testmode 265 lwasm_errorcode_t err_testmode; // error code in testmode
253 line_t *prev; // previous line 266 line_t *prev; // previous line
254 line_t *next; // next line 267 line_t *next; // next line
358 int execaddr; // address from "end" 371 int execaddr; // address from "end"
359 int inmod; // inside an os9 module? 372 int inmod; // inside an os9 module?
360 int undefzero; // used for handling "condundefzero" 373 int undefzero; // used for handling "condundefzero"
361 int pretendmax; // set if we need to pretend the instruction is max length 374 int pretendmax; // set if we need to pretend the instruction is max length
362 unsigned char crc[3]; // crc accumulator 375 unsigned char crc[3]; // crc accumulator
376 int cycle_total; // cycle count accumulator
363 int badsymerr; // throw error on undef sym if set 377 int badsymerr; // throw error on undef sym if set
364 378
365 line_t *line_head; // start of lines list 379 line_t *line_head; // start of lines list
366 line_t *line_tail; // tail of lines list 380 line_t *line_tail; // tail of lines list
367 381
397 }; 411 };
398 412
399 struct symtabe *register_symbol(asmstate_t *as, line_t *cl, char *sym, lw_expr_t value, int flags); 413 struct symtabe *register_symbol(asmstate_t *as, line_t *cl, char *sym, lw_expr_t value, int flags);
400 struct symtabe *lookup_symbol(asmstate_t *as, line_t *cl, char *sym); 414 struct symtabe *lookup_symbol(asmstate_t *as, line_t *cl, char *sym);
401 415
416 int lwasm_cycle_calc_ind(line_t *cl);
417 int lwasm_cycle_calc_rlist(line_t *cl);
418 void lwasm_cycle_update_count(line_t *cl, int opc);
419
402 void lwasm_parse_testmode_comment(line_t *cl, lwasm_testflags_t *flags, lwasm_errorcode_t *err, int *len, char **buf); 420 void lwasm_parse_testmode_comment(line_t *cl, lwasm_testflags_t *flags, lwasm_errorcode_t *err, int *len, char **buf);
403 void lwasm_error_testmode(line_t *cl, const char* msg, int fatal); 421 void lwasm_error_testmode(line_t *cl, const char* msg, int fatal);
404 422
405 void lwasm_register_error(asmstate_t *as, line_t *cl, lwasm_errorcode_t err); 423 void lwasm_register_error(asmstate_t *as, line_t *cl, lwasm_errorcode_t err);
406 void lwasm_register_error2(asmstate_t *as, line_t *cl, lwasm_errorcode_t err, const char* fmt, ...); 424 void lwasm_register_error2(asmstate_t *as, line_t *cl, lwasm_errorcode_t err, const char* fmt, ...);