17 [0] {mcrf, "mcrf", Ibranch},
18 [16] {bclr, "bclr", Ibranch},
19 [33] {crop, "crnor", Ibranch},
20 [15] {0, "rfi", Ibranch},
21 [129] {crop, "crandc", Ibranch},
22 [150] {isync, "isync", Ibranch},
23 [193] {crop, "crxor", Ibranch},
24 [225] {crop, "crnand", Ibranch},
25 [257] {crop, "crand", Ibranch},
26 [289] {crop, "creqv", Ibranch},
27 [417] {crop, "crorc", Ibranch},
28 [449] {crop, "cror", Ibranch},
29 [528] {bcctr, "bcctr", Ibranch},
33 Inset ops19 = {op19, nelem(op19)-1};
41 case 0: return "dnzf";
44 case 4: return "dnzt";
51 sprint(buf, "%d?", bo);
62 static char *f0[] = {"lt", "gt", "eq", "so/un"};
64 if(bo == 0x14){ /* branch always */
68 for(f = 0; bi >= 4; bi -= 4)
71 p += sprint(buf, "%d[", bi);
73 p += sprint(buf, "cr%d+", f);
80 condok(ulong ir, int ctr)
92 if(bo & 0x4 || (reg.ctr!=0)^((bo>>1)&1)) {
93 if(bo & 0x10 || (((reg.cr & bits[bi])!=0)==((bo>>3)&1)))
100 dobranch(ulong ir, ulong *r, int ctr)
107 if(condok(ir, ctr)) {
110 if(bo & 4) /* assume counting branches aren't returns */
115 itrace("%s%s\t%s,%s,#%.8lux", ci->name, ir&1? "l": "", boname(bo), cname(bo, bi), nia);
127 dobranch(ir, ®.ctr, 1);
133 dobranch(ir, ®.lr, 0);
142 static char *opc[] = {"bc", "bcl", "bca", "bcla"};
149 if((ir & 2) == 0) { /* not absolute address */
152 itrace("%s\t%s,%s,.%s%ld\tea = #%.8lux", opc[ir&3], boname(bo), cname(bo, bi), imm<0?"":"+", imm, ea);
156 itrace("%s\t%s,%s,#%.8lux", opc[ir&3], boname(bo), cname(bo, bi), ea);
158 if(condok(ir&0xFFFF0000, 1))
177 itrace("%s\tcrb%d,crb%d,crb%d", ci->name, rd, ra, rb);
178 ra = (reg.cr & bits[ra]) != 0;
179 rb = (reg.cr & bits[rb]) != 0;
182 case 257: d = ra & rb; break;
183 case 129: d = ra & !rb; break;
184 case 289: d = ra == rb; break;
185 case 225: d = !(ra & rb); break;
186 case 33: d = !(ra | rb); break;
187 case 449: d = ra | rb; break;
188 case 417: d = ra | !rb; break;
189 case 193: d = ra ^ rb; break;
190 default: undef(ir); break;
202 if(ir & 1 || rd & 3 || ra & 3 || rb)
206 reg.cr = (reg.cr & ~mkCR(rd, 0xF)) | mkCR(rd, getCR(ra, reg.cr));
208 itrace("mcrf\tcrf%d,crf%d", rd, ra);
217 findsym(npc, CTEXT, &s);
218 Bprint(bioout, "%8lux %s(", reg.pc, s.name);
219 printparams(&s, reg.r[1]);
220 Bprint(bioout, "from ");
232 findsym(npc, CTEXT, &s);
233 Bprint(bioout, "%8lux return to #%lux %s r3=#%lux (%ld)\n",
234 reg.pc, npc, s.name, reg.r[3], reg.r[3]);
243 static char *opc[] = {"b", "bl", "ba", "bla"};
245 imm = ir & 0x03FFFFFC;
248 if((ir & 2) == 0) { /* not absolute address */
251 itrace("%s\t.%s%ld\tea = #%.8lux", opc[ir&3], imm<0?"":"+", imm, ea);
255 itrace("%s\t#%.8lux", opc[ir&3], ea);