comparison src/list.c @ 72:9fa4f77dd119

Fixed tab handling in list code; also added address to second and later lines in byte listing for a particular line
author lost
date Tue, 06 Jan 2009 06:20:31 +0000
parents b1d81800bc91
children dbf1b926c2f1
comparison
equal deleted inserted replaced
71:90a5657d5408 72:9fa4f77dd119
47 47
48 void lwasm_list(asmstate_t *as) 48 void lwasm_list(asmstate_t *as)
49 { 49 {
50 FILE *lf; 50 FILE *lf;
51 lwasm_line_t *l; 51 lwasm_line_t *l;
52 int c; 52 int c, c3;
53 char *p; 53 char *p;
54 54
55 if (as -> listfile[0] == '-' && as -> listfile[1] == '\0') 55 if (as -> listfile[0] == '-' && as -> listfile[1] == '\0')
56 lf = stdout; 56 lf = stdout;
57 else 57 else
93 } 93 }
94 } 94 }
95 fprintf(lf, " %20.20s:%05d ", l -> filename, l -> lineno); 95 fprintf(lf, " %20.20s:%05d ", l -> filename, l -> lineno);
96 96
97 // print line here 97 // print line here
98 for (c = 0, p = l -> text; *p; c++, p++) 98 for (c3 = 0, c = 0, p = l -> text; *p; c++, p++)
99 { 99 {
100 if (*p == '\t') 100 if (*p == '\t')
101 { 101 {
102 int c2; 102 int c2;
103 c2 = 8 - (c % 8); 103 c2 = 8 - (c3 % 8);
104 c3 += c2;
104 while (c2--) fputc(' ', lf); 105 while (c2--) fputc(' ', lf);
105 } 106 }
106 else 107 else
108 {
109 c3++;
107 fputc(*p, lf); 110 fputc(*p, lf);
111 }
108 } 112 }
109 fputc('\n', lf); 113 fputc('\n', lf);
110 114
111 if (l -> codelen > 5) 115 if (l -> codelen > 5)
112 { 116 {
113 fprintf(lf, " "); 117 fprintf(lf, "%04X ", (l -> codeaddr + 5) & 0xFFFF);
114 for (c = 5; c < l -> codelen; c++) 118 for (c = 5; c < l -> codelen; c++)
115 { 119 {
116 if (!(c % 5) && c != 5) 120 if (!(c % 5) && c != 5)
117 { 121 {
118 fprintf(lf, "\n "); 122 fprintf(lf, "\n%04X ", (l -> codeaddr + c) & 0xFFFF);
119 } 123 }
120 fprintf(lf, "%02X", l -> bytes[c]); 124 fprintf(lf, "%02X", l -> bytes[c]);
121 } 125 }
122 fputc('\n', lf); 126 fputc('\n', lf);
123 } 127 }