7 fmtinstall('A', Aconv);
8 fmtinstall('C', Cconv);
9 fmtinstall('D', Dconv);
10 fmtinstall('P', Pconv);
11 fmtinstall('S', Sconv);
12 fmtinstall('N', Nconv);
28 p = va_arg(fp->args, Prog*);
34 snprint(str, sizeof str, "(%ld) %A%C %D,%D",
35 p->line, a, p->scond, &p->from, &p->to);
37 if(p->from.type != D_FREG)
38 snprint(str, sizeof str, "(%ld) %A%C %D,R%d,%D",
39 p->line, a, p->scond, &p->from, p->reg, &p->to);
41 snprint(str, sizeof str, "(%ld) %A%C %D,F%d,%D",
42 p->line, a, p->scond, &p->from, p->reg, &p->to);
47 snprint(str, sizeof str, "(%ld) %A%C R%d,%D,%D",
48 p->line, a, p->scond, p->reg, &p->from, &p->to);
54 snprint(str, sizeof str, "(%ld) %A%C %D/%d,%D",
55 p->line, a, p->scond, &p->from, p->reg, &p->to);
58 return fmtstrcpy(fp, str);
67 a = va_arg(fp->args, int);
69 if(a >= AXXX && a < ALAST)
71 return fmtstrcpy(fp, s);
100 c = va_arg(fp->args, int);
101 strcpy(s, strcond[c & C_SCOND]);
108 if(c & C_UBIT) /* ambiguous with FBIT */
110 return fmtstrcpy(fp, s);
121 a = va_arg(fp->args, Adr*);
125 snprint(str, sizeof str, "GOK-type(%d)", a->type);
130 if(a->name != D_NONE || a->reg != NREG || a->sym != S)
131 snprint(str, sizeof str, "%N(R%d)(NONE)", a, a->reg);
136 snprint(str, sizeof str, "$%N", a);
138 snprint(str, sizeof str, "$%N(R%d)", a, a->reg);
143 op = "<<>>->@>" + (((v>>5) & 3) << 1);
145 snprint(str, sizeof str, "R%ld%c%cR%ld", v&15, op[0], op[1], (v>>8)&15);
148 if(sh == 0 && (v & (3<<5)) != 0)
150 snprint(str, sizeof str, "R%ld%c%c%ld", v&15, op[0], op[1], sh);
153 snprint(str+strlen(str), sizeof(str)-strlen(str), "(R%d)", a->reg);
157 snprint(str, sizeof str, "$*$%N", a);
159 snprint(str, sizeof str, "%N(R%d)(CONST)", a, a->reg);
164 snprint(str, sizeof str, "%N(R%d)", a, a->reg);
166 snprint(str, sizeof str, "%N", a);
170 snprint(str, sizeof str, "R%d", a->reg);
171 if(a->name != D_NONE || a->sym != S)
172 snprint(str, sizeof str, "%N(R%d)(REG)", a, a->reg);
176 snprint(str, sizeof str, "(R%d,R%d)", a->reg, (int)a->offset);
177 if(a->name != D_NONE || a->sym != S)
178 snprint(str, sizeof str, "%N(R%d)(REG)", a, a->reg);
182 snprint(str, sizeof str, "F%d", a->reg);
183 if(a->name != D_NONE || a->sym != S)
184 snprint(str, sizeof str, "%N(R%d)(REG)", a, a->reg);
190 snprint(str, sizeof str, "CPSR");
193 snprint(str, sizeof str, "SPSR");
196 snprint(str, sizeof str, "PSR%d", a->reg);
199 if(a->name != D_NONE || a->sym != S)
200 snprint(str, sizeof str, "%N(PSR%d)(REG)", a, a->reg);
206 snprint(str, sizeof str, "FPSR");
209 snprint(str, sizeof str, "FPCR");
212 snprint(str, sizeof str, "FCR%d", a->reg);
215 if(a->name != D_NONE || a->sym != S)
216 snprint(str, sizeof str, "%N(FCR%d)(REG)", a, a->reg);
220 case D_BRANCH: /* botch */
221 if(curp->cond != P) {
224 snprint(str, sizeof str, "%s+%.5lux(BRANCH)", a->sym->name, v);
226 snprint(str, sizeof str, "%.5lux(BRANCH)", v);
229 snprint(str, sizeof str, "%s+%ld(APC)", a->sym->name, a->offset);
231 snprint(str, sizeof str, "%ld(APC)", a->offset);
235 snprint(str, sizeof str, "$%e", ieeedtod(a->ieee));
239 snprint(str, sizeof str, "$\"%S\"", a->sval);
242 return fmtstrcpy(fp, str);
252 a = va_arg(fp->args, Adr*);
256 snprint(str, sizeof str, "GOK-name(%d)", a->name);
260 snprint(str, sizeof str, "%ld", a->offset);
265 snprint(str, sizeof str, "%ld(SB)", a->offset);
267 snprint(str, sizeof str, "%s+%ld(SB)", s->name, a->offset);
272 snprint(str, sizeof str, "<>+%ld(SB)", a->offset);
274 snprint(str, sizeof str, "%s<>+%ld(SB)", s->name, a->offset);
279 snprint(str, sizeof str, "%ld(SP)", a->offset);
281 snprint(str, sizeof str, "%s-%ld(SP)", s->name, -a->offset);
286 snprint(str, sizeof str, "%ld(FP)", a->offset);
288 snprint(str, sizeof str, "%s+%ld(FP)", s->name, a->offset);
291 return fmtstrcpy(fp, str);
298 char str[STRINGSZ], *p, *a;
300 a = va_arg(fp->args, char*);
302 for(i=0; i<sizeof(long); i++) {
304 if(c >= 'a' && c <= 'z' ||
305 c >= 'A' && c <= 'Z' ||
306 c >= '0' && c <= '9' ||
307 c == ' ' || c == '%') {
328 *p++ = ((c>>3) & 7) + '0';
329 *p++ = (c & 7) + '0';
332 return fmtstrcpy(fp, str);
338 char buf[STRINGSZ], *tn;
342 if(curtext != P && curtext->from.sym != S)
343 tn = curtext->from.sym->name;
345 vseprint(buf, buf+sizeof(buf), fmt, arg);
347 print("%s: %s\n", tn, buf);
351 print("too many errors\n");