Mercurial > hg > index.cgi
diff lwasm/list.c @ 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 | b6933dc299e6 |
children | 1ebb5a0b2874 |
line wrap: on
line diff
--- a/lwasm/list.c Mon Jul 13 20:35:16 2015 -0600 +++ b/lwasm/list.c Mon Jul 13 20:47:30 2015 -0600 @@ -66,7 +66,6 @@ for (cl = as -> line_head; cl; cl = nl) { char *linespec; - int linespec_len; nl = cl -> next; if (CURPRAGMA(cl, PRAGMA_NOLIST)) @@ -194,15 +193,67 @@ } fprintf(of, " "); } - /* the 32.32 below is deliberately chosen so that the start of the line text is at - a multiple of 8 from the start of the list line */ - linespec = cl -> linespec; - linespec_len = strlen(linespec); - if (linespec_len > 32) + + /* the format specifier below is deliberately chosen so that the start of the line text is at + a multiple of 8 from the start of the list line */ + + #define max_linespec_len 17 + + // trim "include:" if it appears + linespec = cl -> linespec; + if ((strlen(linespec) > 8) && (linespec[7] == ':')) linespec += 8; + while (*linespec == ' ') linespec++; + + fprintf(of, "(%*.*s):%05d ", max_linespec_len, max_linespec_len, linespec, cl->lineno); + + if (CURPRAGMA(cl, PRAGMA_CC)) + { + as->cycle_total = 0; + } + + /* display cycle counts */ + char s[64] = ""; + if (CURPRAGMA(cl, PRAGMA_C) || CURPRAGMA(cl, PRAGMA_CD)) { - linespec += linespec_len - 32; + if (cl->cycle_base != 0) + { + char ch = '('; + if (CURPRAGMA(cl, PRAGMA_6809)) ch = '['; + + if (CURPRAGMA(cl, PRAGMA_CD) && cl->cycle_flags & CYCLE_ADJ) + { + sprintf(s, "%c%d+%d", ch, cl->cycle_base, cl->cycle_adj); /* detailed cycle count */ + } + else + { + sprintf(s, "%c%d", ch, cl->cycle_base + cl->cycle_adj); /* normal cycle count*/ + } + + if (cl->cycle_flags & CYCLE_ESTIMATED) + strcat(s, "+?"); + + as->cycle_total += cl->cycle_base + cl->cycle_adj; + + ch = ')'; + if (CURPRAGMA(cl, PRAGMA_6809)) ch = ']'; + sprintf(s, "%s%c", s, ch); + } } - fprintf(of, "(%32.32s):%05d ", linespec, cl -> lineno); + + fprintf(of, "%-8s", s); + + if (CURPRAGMA(cl, PRAGMA_CT)) + { + if (cl->cycle_base != 0) + { + fprintf(of, "%-8d", as->cycle_total); + } + else + { + fprintf(of, " "); + } + } + i = 0; for (tc = cl -> ltext; *tc; tc++) {