home *** CD-ROM | disk | FTP | other *** search
- #include "diblock.h"
- #include "instrn.h"
-
- extern dinstrn *i_absfmt();
- extern dinstrn *i_add();
- extern dinstrn *i_addfmt();
- extern dinstrn *i_addi();
- extern dinstrn *i_addiu();
- extern dinstrn *i_addu();
- extern dinstrn *i_and();
- extern dinstrn *i_andi();
- extern dinstrn *i_bc1f();
- extern dinstrn *i_bc1t();
- extern dinstrn *i_beq();
- extern dinstrn *i_bgez();
- extern dinstrn *i_bgtz();
- extern dinstrn *i_blez();
- extern dinstrn *i_bltz();
- extern dinstrn *i_bne();
- extern dinstrn *i_ceq();
- extern dinstrn *i_cfc1();
- extern dinstrn *i_cle();
- extern dinstrn *i_clt();
- extern dinstrn *i_cole();
- extern dinstrn *i_colt();
- extern dinstrn *i_ctc1();
- extern dinstrn *i_cule();
- extern dinstrn *i_cult();
- extern dinstrn *i_cvtd();
- extern dinstrn *i_cvts();
- extern dinstrn *i_cvtw();
- extern dinstrn *i_div();
- extern dinstrn *i_divfmt();
- extern dinstrn *i_divu();
- extern dinstrn *i_j();
- extern dinstrn *i_jal();
- extern dinstrn *i_jalr();
- extern dinstrn *i_jr();
- extern dinstrn *i_lb();
- extern dinstrn *i_lbu();
- extern dinstrn *i_lh();
- extern dinstrn *i_lhu();
- extern dinstrn *i_lui();
- extern dinstrn *i_lw();
- extern dinstrn *i_lwc1();
- extern dinstrn *i_lwl();
- extern dinstrn *i_lwr();
- extern dinstrn *i_mfc1();
- extern dinstrn *i_mfhi();
- extern dinstrn *i_mflo();
- extern dinstrn *i_mtc1();
- extern dinstrn *i_mthi();
- extern dinstrn *i_mtlo();
- extern dinstrn *i_mulfmt();
- extern dinstrn *i_mult();
- extern dinstrn *i_multu();
- extern dinstrn *i_movfmt();
- extern dinstrn *i_negfmt();
- extern dinstrn *i_nor();
- extern dinstrn *i_or();
- extern dinstrn *i_ori();
- extern dinstrn *i_sb();
- extern dinstrn *i_sh();
- extern dinstrn *i_sll();
- extern dinstrn *i_sllv();
- extern dinstrn *i_slt();
- extern dinstrn *i_slti();
- extern dinstrn *i_sltiu();
- extern dinstrn *i_sltu();
- extern dinstrn *i_sra();
- extern dinstrn *i_srav();
- extern dinstrn *i_srl();
- extern dinstrn *i_srlv();
- extern dinstrn *i_sub();
- extern dinstrn *i_subfmt();
- extern dinstrn *i_subu();
- extern dinstrn *i_sw();
- extern dinstrn *i_swc1();
- extern dinstrn *i_swl();
- extern dinstrn *i_swr();
- extern dinstrn *i_syscall();
- extern dinstrn *i_undef();
- extern dinstrn *i_xor();
- extern dinstrn *i_xori();
-
- /*
- * The primary opcode instruction table.
- */
- instrn optab[] =
- {
- OP("special", IF_R, i_undef, "????"),
- OP("bcond", IF_I, i_undef, "????"),
- OP("j", IF_J, i_j, "a-31"),
- OP("jal", IF_J, i_jal, "a-32"),
- OP("beq", IF_I, i_beq, "a-17"),
- OP("bne", IF_I, i_bne, "a-24"),
- OP("blez", IF_I, i_blez, "a-21"),
- OP("bgtz", IF_I, i_bgtz, "a-20"),
-
- OP("addi", IF_I, i_addi, "a-10"),
- OP("addiu", IF_I, i_addiu, "a-11"),
- OP("slti", IF_I, i_slti, "a-65"),
- OP("sltiu", IF_I, i_sltiu, "a-66"),
- OP("andi", IF_I, i_andi, "a-14"),
- OP("ori", IF_I, i_ori, "a-58"),
- OP("xori", IF_I, i_xori, "a-86"),
- OP("lui", IF_I, i_lui, "a-39"),
-
- OP("cop0", IF_R, i_undef, "a-27"),
- OP("cop1", IF_U, i_undef, "a-27"),
- OP("cop2", IF_U, i_undef, "a-27"),
- OP("cop3", IF_U, i_undef, "a-27"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
-
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
-
- OP("lb", IF_I, i_lb, "a-35"),
- OP("lh", IF_I, i_lh, "a-37"),
- OP("lwl", IF_I, i_lwl, "a-42"),
- OP("lw", IF_I, i_lw, "a-40"),
- OP("lbu", IF_I, i_lbu, "a-36"),
- OP("lhu", IF_I, i_lhu, "a-38"),
- OP("lwr", IF_I, i_lwr, "a-44"),
- OP("", IF_U, i_undef, "????"),
-
- OP("sb", IF_I, i_sb, "a-60"),
- OP("sh", IF_I, i_sh, "a-61"),
- OP("swl", IF_I, i_swl, "a-76"),
- OP("sw", IF_I, i_sw, "a-74"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("swr", IF_I, i_swr, "a-78"),
- OP("", IF_U, i_undef, "????"),
-
- OP("lwc0", IF_U, i_undef, "a-41"),
- OP("lwc1", IF_I, i_lwc1, "b-20"),
- OP("lwc2", IF_U, i_undef, "a-41"),
- OP("lwc3", IF_U, i_undef, "a-41"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
-
- OP("swc0", IF_U, i_undef, "a-75"),
- OP("swc1", IF_I, i_swc1, "b-27"),
- OP("swc2", IF_U, i_undef, "a-75"),
- OP("swc3", IF_U, i_undef, "a-75"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
- OP("", IF_U, i_undef, "????"),
-
- OP("", IF_U, i_undef, "????"),
- };
-
- /*
- * The special opcode instruction table.
- */
- instrn optab_special[] =
- {
- OP("sll", IF_R, i_sll, "a-62"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("srl", IF_R, i_srl, "a-70"),
- OP("sra", IF_R, i_sra, "a-68"),
- OP("sllv", IF_R, i_sllv, "a-63"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("srlv", IF_R, i_srlv, "a-71"),
- OP("srav", IF_R, i_srav, "a-69"),
-
- OP("jr", IF_R, i_jr, "a-34"),
- OP("jalr", IF_R, i_jalr, "a-33"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("syscall", IF_R, i_syscall, "a-80"),
- OP("break", IF_U, i_undef, "a-25"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
-
- OP("mfhi", IF_R, i_mfhi, "a-48"),
- OP("mthi", IF_R, i_mthi, "a-52"),
- OP("mflo", IF_R, i_mflo, "a-49"),
- OP("mtlo", IF_R, i_mtlo, "a-53"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
-
- OP("mult", IF_R, i_mult, "a-54"),
- OP("multu", IF_R, i_multu, "a-55"),
- OP("div", IF_R, i_div, "a-29"),
- OP("divu", IF_R, i_divu, "a-30"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
-
- OP("add", IF_R, i_add, "a-09"),
- OP("addu", IF_R, i_addu, "a-12"),
- OP("sub", IF_R, i_sub, "a-72"),
- OP("subu", IF_R, i_subu, "a-73"),
- OP("and", IF_R, i_and, "a-13"),
- OP("or", IF_R, i_or, "a-57"),
- OP("xor", IF_R, i_xor, "a-85"),
- OP("nor", IF_R, i_nor, "a-56"),
-
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("slt", IF_R, i_slt, "a-64"),
- OP("sltu", IF_R, i_sltu, "a-67"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
-
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
-
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
- OP("<special>", IF_U, i_undef, "????"),
-
- OP("", IF_U, i_undef, "????"),
- };
-
- /*
- * The bcond opcode instruction table.
- */
- instrn optab_bcond[] =
- {
- OP("bltz", IF_I, i_bltz, "a-22"),
- OP("bgez", IF_I, i_bgez, "a-18"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
-
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
-
- OP("bltzal", IF_I, i_undef, "a-23"),
- OP("bgezal", IF_I, i_undef, "a-19"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
-
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
- OP("<bcond>", IF_U, i_undef, "????"),
-
- OP("", IF_U, i_undef, "????"),
- };
-
- /*
- * The cop0 opcode instruction table.
- */
- instrn optab_cop0[] =
- {
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("tlbr", IF_U, i_undef, "a-82"),
- OP("tlbwi", IF_U, i_undef, "a-83"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("tlbwr", IF_U, i_undef, "a-84"),
- OP("<cop0>", IF_U, i_undef, "????"),
-
- OP("tlbp", IF_U, i_undef, "a-81"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
-
- OP("rfe", IF_U, i_undef, "a-59"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
-
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
- OP("<cop0>", IF_U, i_undef, "????"),
-
- OP("", IF_U, i_undef, "????"),
- };
-
- /*
- * The cop1 group1 opcode instruction table.
- */
- instrn optab_cop1_group1[] =
- {
- OP("mfc1", IF_M1, i_mfc1, "b-21"),
- OP("mfc1", IF_M1, i_mfc1, "b-21"),
- OP("cfc1", IF_C1, i_cfc1, "b-14"),
- OP("cfc1", IF_C1, i_cfc1, "b-14"),
- OP("mtc1", IF_M1, i_mtc1, "b-23"),
- OP("mtc1", IF_M1, i_mtc1, "b-23"),
- OP("ctc1", IF_C1, i_ctc1, "b-15"),
- OP("ctc1", IF_C1, i_ctc1, "b-15"),
-
- OP("bc1f", IF_I1, i_bc1f, "b-10"),
- OP("bc1t", IF_I1, i_bc1t, "b-11"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("bc1f", IF_I1, i_bc1f, "b-10"),
- OP("bc1t", IF_I1, i_bc1t, "b-11"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
-
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
-
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
-
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
-
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
-
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
-
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
- OP("<cop1.1>", IF_U, i_undef, "????"),
-
- OP("", IF_U, i_undef, "????"),
- };
-
- /*
- * The cop1 group2 opcode instruction table.
- */
- instrn optab_cop1_group2[] =
- {
- OP("add.fmt", IF_R1, i_addfmt, "b-09"),
- OP("sub.fmt", IF_R1, i_subfmt, "b-26"),
- OP("mul.fmt", IF_R1, i_mulfmt, "b-24"),
- OP("div.fmt", IF_R1, i_divfmt, "b-19"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("abs.fmt", IF_R1, i_absfmt, "b-08"),
- OP("mov.fmt", IF_R1, i_movfmt, "b-22"),
- OP("neg.fmt", IF_R1, i_negfmt, "b-25"),
-
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
-
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
-
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
-
- OP("cvt.s", IF_R1, i_cvts, "b-17"),
- OP("cvt.d", IF_R1, i_cvtd, "b-16"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("cvt.w", IF_R1, i_cvtw, "b-18"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
-
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
- OP("<cop1.2>", IF_U, i_undef, "????"),
-
- OP("c.f", IF_R1, i_undef, "b-12"),
- OP("c.un", IF_R1, i_undef, "b-12"),
- OP("c.eq", IF_R1, i_ceq, "b-12"),
- OP("c.ueq", IF_R1, i_undef, "b-12"),
- OP("c.olt", IF_R1, i_colt, "b-12"),
- OP("c.ult", IF_R1, i_cult, "b-12"),
- OP("c.ole", IF_R1, i_cole, "b-12"),
- OP("c.ule", IF_R1, i_cule, "b-12"),
-
- OP("c.sf", IF_R1, i_undef, "b-12"),
- OP("c.ngle", IF_R1, i_undef, "b-12"),
- OP("c.seq", IF_R1, i_undef, "b-12"),
- OP("c.ngl", IF_R1, i_undef, "b-12"),
- OP("c.lt", IF_R1, i_clt, "b-12"),
- OP("c.nge", IF_R1, i_undef, "b-12"),
- OP("c.le", IF_R1, i_cle, "b-12"),
- OP("c.ngt", IF_R1, i_undef, "b-12"),
-
- OP("", IF_U, i_undef, "????"),
- };
-
- instrn *
- getip(i)
- unsigned long i;
- {
- unsigned long opindex;
- instrn *ip;
-
- opindex = i_to_op(i);
-
- switch (opindex)
- {
- case 0: /* special */
- ip = &optab_special[i_to_funct(i)];
- break;
-
- case 1: /* bcond */
- ip = &optab_bcond[i_to_rt(i)];
- break;
-
- case 16: /* coprocessor 0 */
- ip = &optab_cop0[i_to_funct(i) & 0x1F];
- break;
-
- case 17: /* coprocessor 1 */
- if (is_cop1_group1(i))
- ip = &optab_cop1_group1[i_to_cop1_group1(i)];
- else
- ip = &optab_cop1_group2[i_to_cop1_group2(i)];
- break;
-
- default:
- ip = &optab[opindex];
- break;
- }
-
- return ip;
- }
-