comparison 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
comparison
equal deleted inserted replaced
375:71f507f404f1 376:35d4213e6657
64 } 64 }
65 65
66 for (cl = as -> line_head; cl; cl = nl) 66 for (cl = as -> line_head; cl; cl = nl)
67 { 67 {
68 char *linespec; 68 char *linespec;
69 int linespec_len;
70 69
71 nl = cl -> next; 70 nl = cl -> next;
72 if (CURPRAGMA(cl, PRAGMA_NOLIST)) 71 if (CURPRAGMA(cl, PRAGMA_NOLIST))
73 { 72 {
74 if (cl -> outputl <= 0) 73 if (cl -> outputl <= 0)
192 { 191 {
193 fprintf(of, " "); 192 fprintf(of, " ");
194 } 193 }
195 fprintf(of, " "); 194 fprintf(of, " ");
196 } 195 }
197 /* the 32.32 below is deliberately chosen so that the start of the line text is at 196
198 a multiple of 8 from the start of the list line */ 197 /* the format specifier below is deliberately chosen so that the start of the line text is at
198 a multiple of 8 from the start of the list line */
199
200 #define max_linespec_len 17
201
202 // trim "include:" if it appears
199 linespec = cl -> linespec; 203 linespec = cl -> linespec;
200 linespec_len = strlen(linespec); 204 if ((strlen(linespec) > 8) && (linespec[7] == ':')) linespec += 8;
201 if (linespec_len > 32) 205 while (*linespec == ' ') linespec++;
202 { 206
203 linespec += linespec_len - 32; 207 fprintf(of, "(%*.*s):%05d ", max_linespec_len, max_linespec_len, linespec, cl->lineno);
204 } 208
205 fprintf(of, "(%32.32s):%05d ", linespec, cl -> lineno); 209 if (CURPRAGMA(cl, PRAGMA_CC))
210 {
211 as->cycle_total = 0;
212 }
213
214 /* display cycle counts */
215 char s[64] = "";
216 if (CURPRAGMA(cl, PRAGMA_C) || CURPRAGMA(cl, PRAGMA_CD))
217 {
218 if (cl->cycle_base != 0)
219 {
220 char ch = '(';
221 if (CURPRAGMA(cl, PRAGMA_6809)) ch = '[';
222
223 if (CURPRAGMA(cl, PRAGMA_CD) && cl->cycle_flags & CYCLE_ADJ)
224 {
225 sprintf(s, "%c%d+%d", ch, cl->cycle_base, cl->cycle_adj); /* detailed cycle count */
226 }
227 else
228 {
229 sprintf(s, "%c%d", ch, cl->cycle_base + cl->cycle_adj); /* normal cycle count*/
230 }
231
232 if (cl->cycle_flags & CYCLE_ESTIMATED)
233 strcat(s, "+?");
234
235 as->cycle_total += cl->cycle_base + cl->cycle_adj;
236
237 ch = ')';
238 if (CURPRAGMA(cl, PRAGMA_6809)) ch = ']';
239 sprintf(s, "%s%c", s, ch);
240 }
241 }
242
243 fprintf(of, "%-8s", s);
244
245 if (CURPRAGMA(cl, PRAGMA_CT))
246 {
247 if (cl->cycle_base != 0)
248 {
249 fprintf(of, "%-8d", as->cycle_total);
250 }
251 else
252 {
253 fprintf(of, " ");
254 }
255 }
256
206 i = 0; 257 i = 0;
207 for (tc = cl -> ltext; *tc; tc++) 258 for (tc = cl -> ltext; *tc; tc++)
208 { 259 {
209 if ((*tc) == '\t') 260 if ((*tc) == '\t')
210 { 261 {