📄 vdb.c
字号:
"SRL", sllv, "R%s,R%t,R%d", "SRA", sllv, "R%s,R%t,R%d", "JMP", 0, "(R%s)", "jal", jal, "r%d,r%s", "special0A", 0, mipscoxxx, "special0B", 0, mipscoxxx, "SYSCALL", 0, 0, "BREAK", 0, 0, "special0E", 0, mipscoxxx, "SYNC", 0, 0, "MOVW", 0, "HI,R%d", "MOVW", 0, "R%s,HI", "MOVW", 0, "LO,R%d", "MOVW", 0, "R%s,LO", "SLLV", sllv, "R%s,R%t,R%d", "special15", 0, mipscoxxx, "SRLV", sllv, "R%s,R%t,R%d", "SRAV", sllv, "R%s,R%t,R%d", "MUL", 0, mipsrtrs, "MULU", 0, mipsrtrs, "DIV", 0, mipsrtrs, "DIVU", 0, mipsrtrs, "special1C", 0, mipscoxxx, "special1D", 0, mipscoxxx, "DDIV", 0, "R%s,R%t", "special1F", 0, mipscoxxx, "ADD", add, mipsalu3op, "ADDU", add, mipsalu3op, "SUB", sub, mipsalu3op, "SUBU", sub, mipsalu3op, "AND", add, mipsalu3op, "OR", or, mipsalu3op, "XOR", add, mipsalu3op, "NOR", nor, mipsalu3op, "special28", 0, mipscoxxx, "special29", 0, mipscoxxx, "SGT", 0, mipsalu3op, "SGTU", 0, mipsalu3op, "special2C", 0, mipscoxxx, "special2D", 0, mipscoxxx, "special2E", 0, mipscoxxx, "DSUBU", 0, "R%s,R%t,R%d", "tge", 0, mipscorsrt, "tgeu", 0, mipscorsrt, "tlt", 0, mipscorsrt, "tltu", 0, mipscorsrt, "teq", 0, mipscorsrt, "special35", 0, mipscoxxx, "tne", 0, mipscorsrt, "special37", 0, mipscoxxx, "SLLV", sll, "$%a,R%t,R%d", "special39", 0, mipscoxxx, "SRLV", sll, "$%a,R%t,R%d", "SRAV", sll, "$%a,R%t,R%d", "SLLV", sl32, "$%a,R%t,R%d", "special3D", 0, mipscoxxx, "SRLV", sl32, "$%a,R%t,R%d", "SRAV", sl32, "$%a,R%t,R%d",};static Opcode ropcodes[32] = { "BLTZ", branch, 0, "BGEZ", branch, 0, "BLTZL", branch, 0, "BGEZL", branch, 0, "regimm04", 0, mipscoxxx, "regimm05", 0, mipscoxxx, "regimm06", 0, mipscoxxx, "regimm07", 0, mipscoxxx, "tgei", 0, mipscorsi, "tgeiu", 0, mipscorsi, "tlti", 0, mipscorsi, "tltiu", 0, mipscorsi, "teqi", 0, mipscorsi, "regimm0D", 0, mipscoxxx, "tnei", 0, mipscorsi, "regimm0F", 0, mipscoxxx, "BLTZAL", branch, 0, "BGEZAL", branch, 0, "BLTZALL", branch, 0, "BGEZALL", branch, 0, "regimm14", 0, mipscoxxx, "regimm15", 0, mipscoxxx, "regimm16", 0, mipscoxxx, "regimm17", 0, mipscoxxx, "regimm18", 0, mipscoxxx, "regimm19", 0, mipscoxxx, "regimm1A", 0, mipscoxxx, "regimm1B", 0, mipscoxxx, "regimm1C", 0, mipscoxxx, "regimm1D", 0, mipscoxxx, "regimm1E", 0, mipscoxxx, "regimm1F", 0, mipscoxxx,};static Opcode fopcodes[64] = { "ADD%f", 0, mipsfp3, "SUB%f", 0, mipsfp3, "MUL%f", 0, mipsfp3, "DIV%f", 0, mipsfp3, "sqrt.%f", 0, mipscofp2, "ABS%f", 0, mipsfp2, "MOV%f", 0, mipsfp2, "NEG%f", 0, mipsfp2, "finstr08", 0, mipscoxxx, "finstr09", 0, mipscoxxx, "finstr0A", 0, mipscoxxx, "finstr0B", 0, mipscoxxx, "round.w.%f", 0, mipscofp2, "trunc.w%f", 0, mipscofp2, "ceil.w%f", 0, mipscofp2, "floor.w%f", 0, mipscofp2, "finstr10", 0, mipscoxxx, "finstr11", 0, mipscoxxx, "finstr12", 0, mipscoxxx, "finstr13", 0, mipscoxxx, "finstr14", 0, mipscoxxx, "finstr15", 0, mipscoxxx, "finstr16", 0, mipscoxxx, "finstr17", 0, mipscoxxx, "finstr18", 0, mipscoxxx, "finstr19", 0, mipscoxxx, "finstr1A", 0, mipscoxxx, "finstr1B", 0, mipscoxxx, "finstr1C", 0, mipscoxxx, "finstr1D", 0, mipscoxxx, "finstr1E", 0, mipscoxxx, "finstr1F", 0, mipscoxxx, "cvt.s.%f", 0, mipscofp2, "cvt.d.%f", 0, mipscofp2, "cvt.e.%f", 0, mipscofp2, "cvt.q.%f", 0, mipscofp2, "cvt.w.%f", 0, mipscofp2, "finstr25", 0, mipscoxxx, "finstr26", 0, mipscoxxx, "finstr27", 0, mipscoxxx, "finstr28", 0, mipscoxxx, "finstr29", 0, mipscoxxx, "finstr2A", 0, mipscoxxx, "finstr2B", 0, mipscoxxx, "finstr2C", 0, mipscoxxx, "finstr2D", 0, mipscoxxx, "finstr2E", 0, mipscoxxx, "finstr2F", 0, mipscoxxx, "c.f.%f", 0, mipscofpc, "c.un.%f", 0, mipscofpc, "CMPEQ%f", 0, mipsfpc, "c.ueq.%f", 0, mipscofpc, "c.olt.%f", 0, mipscofpc, "c.ult.%f", 0, mipscofpc, "c.ole.%f", 0, mipscofpc, "c.ule.%f", 0, mipscofpc, "c.sf.%f", 0, mipscofpc, "c.ngle.%f", 0, mipscofpc, "c.seq.%f", 0, mipscofpc, "c.ngl.%f", 0, mipscofpc, "CMPGT%f", 0, mipsfpc, "c.nge.%f", 0, mipscofpc, "CMPGE%f", 0, mipsfpc, "c.ngt.%f", 0, mipscofpc,};static char *cop0regs[32] = { "INDEX", "RANDOM", "TLBPHYS", "EntryLo0", "CONTEXT", "PageMask", "Wired", "Error", "BADVADDR", "Count", "TLBVIRT", "Compare", "STATUS", "CAUSE", "EPC", "PRID", "Config", "LLadr", "WatchLo", "WatchHi", "20", "21", "22", "23", "24", "25", "26", "CacheErr", "TagLo", "TagHi", "ErrorEPC", "31"};static char fsub[16] = { 'F', 'D', 'e', 'q', 'W', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?', '?'};static char *cacheps[] = { "I", "D", "SI", "SD"};static char *cacheop[] = { "IWBI", "ILT", "IST", "CDE", "HI", "HWBI", "HWB", "HSV"};static voidformat(char *mnemonic, Instr *i, char *f){ if (mnemonic) format(0, i, mnemonic); if (f == 0) return; if (mnemonic) if (i->curr < i->end) *i->curr++ = '\t'; for ( ; *f && i->curr < i->end; f++) { if (*f != '%') { *i->curr++ = *f; continue; } switch (*++f) { case 's': bprint(i, "%d", i->rs); break; case 't': bprint(i, "%d", i->rt); break; case 'd': bprint(i, "%d", i->rd); break; case 'a': bprint(i, "%d", i->sa); break; case 'l': bprint(i, "%lx(R%d)",i->immediate, i->rs); break; case 'i': bprint(i, "$%lx", i->immediate); break; case 'u': i->curr += symoff(i->curr, i->end-i->curr, i->immediate, CANY); bprint(i, "(SB)"); break; case 'j': i->curr += symoff(i->curr, i->end-i->curr, (i->target<<2)|(i->addr & 0xF0000000), CANY); bprint(i, "(SB)"); break; case 'b': i->curr += symoff(i->curr, i->end-i->curr, (i->immediate<<2)+i->addr+4, CANY); break; case 'c': bprint(i, "$%lx", i->cofun); break; case 'w': bprint(i, "[%lux]", i->w0); break; case 'm': bprint(i, "M(%s)", cop0regs[i->rd]); break; case 'f': *i->curr++ = fsub[i->rs & 0x0F]; break; case 'C': bprint(i, "%s%s", cacheps[i->rt & 3], cacheop[(i->rt>>2) & 7]); break; case '\0': *i->curr++ = '%'; return; default: bprint(i, "%%%c", *f); break; } } *i->curr = 0;}static voidcopz(int cop, Instr *i){ char *f, *m, buf[16]; m = buf; f = "%t,%d"; switch (i->rs) { case 0: sprint(buf, "mfc%d", cop); break; case 2: sprint(buf, "cfc%d", cop); break; case 4: sprint(buf, "mtc%d", cop); break; case 6: sprint(buf, "ctc%d", cop); break; case 8: f = "%b"; switch (i->rt) { case 0: sprint(buf, "bc%df", cop); break; case 1: sprint(buf, "bc%dt", cop); break; case 2: sprint(buf, "bc%dfl", cop); break; case 3: sprint(buf, "bc%dtl", cop); break; default: sprint(buf, "cop%d", cop); f = mipscoxxx; break; } break; default: sprint(buf, "cop%d", cop); if (i->rs & 0x10) f = "function %c"; else f = mipscoxxx; break; } format(m, i, f);}static voidcop0(Instr *i){ char *m = 0; if (i->rs < 8) { switch (i->rs) { case 0: case 1: format("MOVW", i, "%m,R%t"); return; case 4: case 5: format("MOVW", i, "R%t,%m"); return; } } else if (i->rs >= 0x10) { switch (i->cofun) { case 1: m = "TLBR"; break; case 2: m = "TLBWI"; break; case 6: m = "TLBWR"; break; case 8: m = "TLBP"; break; case 16: m = "RFE"; break; case 32: m = "ERET"; break; } if (m) { format(m, i, 0); return; } } copz(0, i);}static voidcop1(Instr *i){ char *m = "MOVW"; switch (i->rs) { case 0: format(m, i, "F%d,R%t"); return; case 2: format(m, i, "FCR%d,R%t"); return; case 4: format(m, i, "R%t,F%d"); return; case 6: format(m, i, "R%t,FCR%d"); return; case 8: switch (i->rt) { case 0: format("BFPF", i, "%b"); return; case 1: format("BFPT", i, "%b"); return; } break; } copz(1, i);}static intprintins(Map *map, uvlong pc, char *buf, int n){ Instr i; Opcode *o; uchar op; i.curr = buf; i.end = buf+n-1; mymap = map; if (mkinstr(pc, &i) < 0) return -1; switch (i.op) { case 0x00: /* SPECIAL */ o = sopcodes; op = i.function; break; case 0x01: /* REGIMM */ o = ropcodes; op = i.rt; break; case 0x10: /* COP0 */ cop0(&i); return i.size*4; case 0x11: /* COP1 */ if (i.rs & 0x10) { o = fopcodes; op = i.function; break; } cop1(&i); return i.size*4; case 0x12: /* COP2 */ case 0x13: /* COP3 */ copz(i.op-0x10, &i); return i.size*4; default: o = opcodes; op = i.op; break; } if (o[op].f) (*o[op].f)(&o[op], &i); else format(o[op].mnemonic, &i, o[op].ken); return i.size*4;}extern int _mipscoinst(Map *, uvlong, char*, int); /* modifier 'I' toggles the default disassembler type */static intmipsinst(Map *map, uvlong pc, char modifier, char *buf, int n){ if ((asstype == AMIPSCO && modifier == 'i') || (asstype == AMIPS && modifier == 'I')) return _mipscoinst(map, pc, buf, n); else return printins(map, pc, buf, n);}static intmipsdas(Map *map, uvlong pc, char *buf, int n){ Instr i; i.curr = buf; i.end = buf+n; mymap = map; if (mkinstr(pc, &i) < 0) return -1; if (i.end-i.curr > 8) i.curr = _hexify(buf, i.w0, 7); if (i.size == 2 && i.end-i.curr > 9) { *i.curr++ = ' '; i.curr = _hexify(i.curr, i.w1, 7); } *i.curr = 0; return i.size*4;}static intmipsinstlen(Map *map, uvlong pc){ Instr i; mymap = map; if (mkinstr(pc, &i) < 0) return -1; return i.size*4;}static intmipsfoll(Map *map, uvlong pc, Rgetter rget, uvlong *foll){ ulong w, l; char buf[8]; Instr i; mymap = map; if (mkinstr(pc, &i) < 0) return -1; w = i.w0; if((w&0xF3600000) == 0x41000000){ /* branch on coprocessor */ Conditional: foll[0] = pc+8; l = ((w&0xFFFF)<<2); if(w & 0x8000) l |= 0xFFFC0000; foll[1] = pc+4 + l; return 2; } l = (w&0xFC000000)>>26; switch(l){ case 0: /* SPECIAL */ if((w&0x3E) == 0x08){ /* JR, JALR */ sprint(buf, "R%ld", (w>>21)&0x1F); foll[0] = (*rget)(map, buf); return 1; } foll[0] = pc+i.size*4; return 1; case 0x30: /* Load-Linked followed by NOP, STC */ foll[0] = pc+12; return 1; case 1: /* BCOND */ case 4: /* BEQ */ case 20: /* BEQL */ case 5: /* BNE */ case 21: /* BNEL */ case 6: /* BLEZ */ case 22: /* BLEZL */ case 7: /* BGTZ */ case 23: /* BGTZL */ goto Conditional; case 2: /* J */ case 3: /* JAL */ foll[0] = (pc&0xF0000000) | ((w&0x03FFFFFF)<<2); return 1; } foll[0] = pc+i.size*4; return 1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -