8 fmtinstall('A', Aconv);
9 fmtinstall('P', Pconv);
10 fmtinstall('S', Sconv);
11 fmtinstall('N', Nconv);
12 fmtinstall('B', Bconv);
13 fmtinstall('D', Dconv);
14 fmtinstall('R', Rconv);
20 char str[STRINGSZ], ss[STRINGSZ], *s;
25 bits = va_arg(fp->args, Bits);
31 snprint(ss, sizeof(ss), "$%lld", var[i].offset);
35 if(strlen(str) + strlen(s) + 1 >= STRINGSZ)
38 bits.b[i/32] &= ~(1L << (i%32));
40 return fmtstrcpy(fp, str);
43 static char *conds[] = {
44 ".EQ", ".NE", ".CS", ".CC",
45 ".MI", ".PL", ".VS", ".VC",
46 ".HI", ".LS", ".GE", ".LT",
47 ".GT", ".LE", "", ".NV",
57 p = va_arg(fp->args, Prog*);
60 snprint(str, sizeof(str), " %A %D/%d,%D", a, &p->from, p->reg, &p->to);
63 snprint(str, sizeof(str), " %A %D,%d,%D", a, &p->from, p->reg, &p->to);
66 snprint(str, sizeof(str), " %A %D,%D", a, &p->from, &p->to);
68 if(p->from.type != D_FREG)
69 snprint(str, sizeof(str), " %A %D,R%d,%D", a, &p->from, p->reg, &p->to);
71 snprint(str, sizeof(str), " %A %D,F%d,%D", a, &p->from, p->reg, &p->to);
72 return fmtstrcpy(fp, str);
81 a = va_arg(fp->args, int);
83 if(a >= AXXX && a < ALAST)
85 return fmtstrcpy(fp, s);
95 static char *extop[] = {".UB", ".UH", ".UW", ".UX", ".SB", ".SH", ".SW", ".SX"};
97 a = va_arg(fp->args, Adr*);
101 snprint(str, sizeof(str), "GOK-type(%d)", a->type);
106 if(a->name != D_NONE || a->reg != NREG || a->sym != S)
107 snprint(str, sizeof(str), "%N(R%d)(NONE)", a, a->reg);
112 snprint(str, sizeof(str), "$%N(R%d)", a, a->reg);
114 snprint(str, sizeof(str), "$%N", a);
119 op = "<<>>->@>" + (((v>>5) & 3) << 1);
121 snprint(str, sizeof(str), "R%d%c%cR%d", v&15, op[0], op[1], (v>>8)&15);
123 snprint(str, sizeof(str), "R%d%c%c%d", v&15, op[0], op[1], (v>>7)&31);
125 sprint(str+strlen(str), "(R%d)", a->reg);
130 snprint(str, sizeof(str), "%N(R%d)", a, a->reg);
132 snprint(str, sizeof(str), "%N", a);
137 snprint(str, sizeof(str), "%N(R%d)!", a, a->reg);
139 snprint(str, sizeof(str), "%N!", a);
144 snprint(str, sizeof(str), "(R%d)%N!", a->reg, a);
146 snprint(str, sizeof(str), "%N!", a);
152 snprint(str, sizeof(str), "R%d%s<<%d", (v>>16)&31, extop[(v>>13)&7], (v>>10)&7);
154 snprint(str, sizeof(str), "R%d%s", (v>>16)&31, extop[(v>>13)&7]);
158 snprint(str, sizeof(str), "R%d", a->reg);
159 if(a->name != D_NONE || a->sym != S)
160 snprint(str, sizeof(str), "%N(R%d)(REG)", a, a->reg);
164 if(a->name != D_NONE || a->sym != S)
165 snprint(str, sizeof(str), "%N(R%d)(REG)", a, a->reg);
171 snprint(str, sizeof(str), "F%d", a->reg);
172 if(a->name != D_NONE || a->sym != S)
173 snprint(str, sizeof(str), "%N(R%d)(REG)", a, a->reg);
178 switch((ulong)a->offset){
189 sprint(str, "SPR(%#llux)", a->offset);
192 if(a->name != D_NONE || a->sym != S)
193 snprint(str, sizeof(str), "%N(SPR(%lld))(REG)", a, a->offset);
197 snprint(str, sizeof(str), "%lld(PC)", a->offset-pc);
201 snprint(str, sizeof(str), "$%.17e", a->dval);
205 snprint(str, sizeof(str), "$\"%S\"", a->sval);
208 return fmtstrcpy(fp, str);
214 char str[STRINGSZ], *p, *e;
218 a = va_arg(fp->args, Adr*);
219 snprint(str, sizeof(str), "GOK-reglist");
229 for(i=0; i<NREG; i++) {
232 p = seprint(p, e, "[R%d", i);
234 p = seprint(p, e, ",R%d", i);
239 return fmtstrcpy(fp, str);
246 char str[STRINGSZ], *p, *a;
248 a = va_arg(fp->args, char*);
250 for(i=0; i<NSNAME; i++) {
252 if(c >= 'a' && c <= 'z' ||
253 c >= 'A' && c <= 'Z' ||
254 c >= '0' && c <= '9' ||
255 c == ' ' || c == '%') {
282 *p++ = ((c>>3) & 7) + '0';
283 *p++ = (c & 7) + '0';
286 return fmtstrcpy(fp, str);
296 a = va_arg(fp->args, Adr*);
299 snprint(str, sizeof(str), "%lld", a->offset);
304 snprint(str, sizeof(str), "GOK-name(%d)", a->name);
308 snprint(str, sizeof(str), "%lld", a->offset);
312 snprint(str, sizeof(str), "%s+%lld(SB)", s->name, a->offset);
316 snprint(str, sizeof(str), "%s<>+%lld(SB)", s->name, a->offset);
320 snprint(str, sizeof(str), "%s-%lld(SP)", s->name, -a->offset);
324 snprint(str, sizeof(str), "%s+%lld(FP)", s->name, a->offset);
328 return fmtstrcpy(fp, str);