Beispiel #1
0
        static Avr8Disassembler()
        {
            var oprecs2 = new OpRec[]
            {
                new BOpRec(Opcode.invalid, ""),
                new BOpRec(Opcode.eor, "D,R"),
                new BOpRec(Opcode.invalid, ""),
                new BOpRec(Opcode.invalid, ""),
            };

            var oprecs94 = new Dictionary <int, OpRec>
            {
                { 0x04F8, new BOpRec(Opcode.cli, "") },
                { 0x0508, new BOpRec(Opcode.ret, "") },
            };

            var oprecs9 = new OpRec[]
            {
                new BOpRec(Opcode.pop, "D"),
                new BOpRec(Opcode.push, "D"),
                new SparseOpRec(0, 12, oprecs94),
                new BOpRec(Opcode.invalid, ""),

                new BOpRec(Opcode.invalid, ""),
                new BOpRec(Opcode.invalid, ""),
                new BOpRec(Opcode.invalid, ""),
                new BOpRec(Opcode.invalid, ""),
            };



            var oprecsB = new OpRec[]
            {
                new BOpRec(Opcode.@in, "D,A"),
                new BOpRec(Opcode.@out, "A,D"),
            };

            oprecs = new OpRec[]
            {
                new BOpRec(Opcode.invalid, ""),
                new BOpRec(Opcode.invalid, ""),
                new GrpOpRec(10, 2, oprecs2),
                new BOpRec(Opcode.invalid, ""),

                new BOpRec(Opcode.invalid, ""),
                new BOpRec(Opcode.invalid, ""),
                new BOpRec(Opcode.invalid, ""),
                new BOpRec(Opcode.invalid, ""),

                new BOpRec(Opcode.invalid, ""),
                new GrpOpRec(9, 3, oprecs9),
                new BOpRec(Opcode.invalid, ""),
                new GrpOpRec(0xB, 1, oprecsB),

                new BOpRec(Opcode.rjmp, "J"),
                new BOpRec(Opcode.rcall, "J"),
                new BOpRec(Opcode.ldi, "d,K"),
                new BOpRec(Opcode.invalid, ""),
            };
        }
Beispiel #2
0
 public Group7OpRec(
     OpRec memInstr,
     params OpRec[] regInstrs)
 {
     this.memInstr  = memInstr;
     this.regInstrs = regInstrs;
 }
Beispiel #3
0
            public override IntelInstruction Decode(X86Disassembler disasm, byte op, string opFormat)
            {
                int  grp = Group - 1;
                byte modRm;

                if (!disasm.TryEnsureModRM(out modRm))
                {
                    return(null);
                }
                OpRec opRec = s_aOpRecGrp[grp * 8 + ((modRm >> 3) & 0x07)];

                return(opRec.Decode(disasm, op, opFormat + format));
            }
Beispiel #4
0
        static Avr8Disassembler()
        {
            var invalid = new BOpRec(Opcode.invalid, "", InstrClass.Invalid);
            var oprecs0 = new OpRec[16]
            {
                new BOpRec(Opcode.invalid, "", InstrClass.Invalid | InstrClass.Zero),
                new BOpRec(Opcode.movw, "p,P"),
                new BOpRec(Opcode.muls, "d,r4"),
                new BOpRec(Opcode.muls, "d,r4"),

                new BOpRec(Opcode.cpc, "D,R"),
                new BOpRec(Opcode.cpc, "D,R"),
                new BOpRec(Opcode.cpc, "D,R"),
                new BOpRec(Opcode.cpc, "D,R"),

                new BOpRec(Opcode.sbc, "D,R"),
                new BOpRec(Opcode.sbc, "D,R"),
                new BOpRec(Opcode.sbc, "D,R"),
                new BOpRec(Opcode.sbc, "D,R"),

                new BOpRec(Opcode.add, "D,R"),
                new BOpRec(Opcode.add, "D,R"),
                new BOpRec(Opcode.add, "D,R"),
                new BOpRec(Opcode.add, "D,R"),
            };

            var oprecs1 = new OpRec[]
            {
                new BOpRec(Opcode.cpse, "D,R"),
                new BOpRec(Opcode.cp, "D,R"),
                new BOpRec(Opcode.sub, "D,R"),
                new BOpRec(Opcode.adc, "D,R"),
            };

            var oprecs2 = new OpRec[]
            {
                new BOpRec(Opcode.and, "D,R"),
                new BOpRec(Opcode.eor, "D,R"),
                new BOpRec(Opcode.or, "D,R"),
                new BOpRec(Opcode.mov, "R,r"),
            };

            var oprecs80 = new OpRec[]
            {
                new BOpRec(Opcode.ld, "D,X"),
                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),

                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),

                new BOpRec(Opcode.ld, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),

                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),
            };

            var decoders_std_Z = new OpRec[]
            {
                new BOpRec(Opcode.st, "Z,D"),
                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),

                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),

                new BOpRec(Opcode.st, "y,D"),
                new BOpRec(Opcode.std, "y,D"),
                new BOpRec(Opcode.std, "y,D"),
                new BOpRec(Opcode.std, "y,D"),

                new BOpRec(Opcode.std, "y,D"),
                new BOpRec(Opcode.std, "y,D"),
                new BOpRec(Opcode.std, "y,D"),
                new BOpRec(Opcode.std, "y,D"),
            };

            var decoders_ldd = new OpRec[]
            {
                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),

                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),
                new BOpRec(Opcode.ldd, "D,z"),

                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),

                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),
                new BOpRec(Opcode.ldd, "D,y"),
            };

            var decoders_std = new OpRec[]
            {
                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),

                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),
                new BOpRec(Opcode.std, "z,D"),

                new BOpRec(Opcode.st, "y,D"),
                new BOpRec(Opcode.std, "y,D"),
                new BOpRec(Opcode.std, "y,D"),
                new BOpRec(Opcode.std, "y,D"),

                new BOpRec(Opcode.std, "y,D"),
                new BOpRec(Opcode.std, "y,D"),
                new BOpRec(Opcode.std, "y,D"),
                new BOpRec(Opcode.std, "y,D"),
            };

            var oprecs8 = new OpRec[8]
            {
                new GrpOpRec(0, 4, oprecs80),
                new GrpOpRec(0, 4, decoders_std_Z),
                new GrpOpRec(0, 4, decoders_ldd),
                new GrpOpRec(0, 4, decoders_std),

                new GrpOpRec(0, 4, decoders_ldd),
                new GrpOpRec(0, 4, decoders_std),
                new GrpOpRec(0, 4, decoders_ldd),
                new GrpOpRec(0, 4, decoders_std),
            };

            var oprecs94_8 = new OpRec[]
            {
                new BOpRec(Opcode.sec, ""),
                new BOpRec(Opcode.sez, ""),
                new BOpRec(Opcode.sen, ""),
                new BOpRec(Opcode.sev, ""),

                new BOpRec(Opcode.ses, ""),
                new BOpRec(Opcode.seh, ""),
                new BOpRec(Opcode.set, ""),
                new BOpRec(Opcode.sei, ""),

                new BOpRec(Opcode.clc, ""),
                new BOpRec(Opcode.clz, ""),
                new BOpRec(Opcode.cln, ""),
                new BOpRec(Opcode.clv, ""),

                new BOpRec(Opcode.cls, ""),
                new BOpRec(Opcode.clh, ""),
                new BOpRec(Opcode.clt, ""),
                new BOpRec(Opcode.cli, ""),

                new BOpRec(Opcode.ret, "", InstrClass.Transfer),
                new BOpRec(Opcode.reti, "", InstrClass.Transfer),
                invalid,
                invalid,

                invalid,
                invalid,
                invalid,
                invalid,

                new BOpRec(Opcode.sleep, ""),
                new BOpRec(Opcode.@break, ""),
                new BOpRec(Opcode.wdr, ""),
                invalid,

                new BOpRec(Opcode.lpm, ""),
                new BOpRec(Opcode.elpm, ""),
                new BOpRec(Opcode.spm, ""),
                new BOpRec(Opcode.spm, ""),
            };

            var oprecs95_8 = new OpRec[]
            {
                new BOpRec(Opcode.ret, "", InstrClass.Transfer),
                new BOpRec(Opcode.reti, "", InstrClass.Transfer),
                invalid,
                invalid,

                invalid,
                invalid,
                invalid,
                invalid,

                new BOpRec(Opcode.sleep, ""),
                new BOpRec(Opcode.@break, ""),
                new BOpRec(Opcode.wdr, ""),
                invalid,

                new BOpRec(Opcode.lpm, ""),
                new BOpRec(Opcode.elpm, ""),
                new BOpRec(Opcode.spm, ""),
                new BOpRec(Opcode.spm, ""),
            };

            var oprecs94_9 = new Dictionary <int, OpRec>
            {
                { 0, new BOpRec(Opcode.ijmp, "", InstrClass.Transfer) },
                { 1, new BOpRec(Opcode.eijmp, "", InstrClass.Transfer) },
                { 16, new BOpRec(Opcode.icall, "", InstrClass.Transfer | InstrClass.Call) },
                { 17, new BOpRec(Opcode.eicall, "", InstrClass.Transfer | InstrClass.Call) },
            };

            var oprecs95_9 = new Dictionary <int, OpRec>
            {
                { 0, new BOpRec(Opcode.icall, "", InstrClass.Transfer | InstrClass.Call) },
                { 1, new BOpRec(Opcode.eicall, "", InstrClass.Transfer | InstrClass.Call) },
            };

            var oprecs90 = new OpRec[]
            {
                new BOpRec(Opcode.lds, "D,w"),
                new BOpRec(Opcode.ld, "D,+Z"),
                new BOpRec(Opcode.ld, "D,-Z"),
                invalid,

                new BOpRec(Opcode.lpm, "D,Z"),
                new BOpRec(Opcode.lpm, "D,+Z"),
                new BOpRec(Opcode.elpm, "D,Z"),
                new BOpRec(Opcode.elpm, "D,+Z"),

                invalid,
                new BOpRec(Opcode.ld, "D,+Y"),
                new BOpRec(Opcode.ld, "D,-Y"),
                invalid,

                new BOpRec(Opcode.ld, "D,X"),
                new BOpRec(Opcode.ld, "D,+X"),
                new BOpRec(Opcode.ld, "D,-X"),
                new BOpRec(Opcode.pop, "D"),
            };

            var oprecs92 = new OpRec[]
            {
                new BOpRec(Opcode.sts, "w,D"),
                new BOpRec(Opcode.st, "+Z,D"),
                new BOpRec(Opcode.st, "-Z,D"),
                invalid,

                invalid,
                invalid,
                invalid,
                invalid,

                invalid,
                new BOpRec(Opcode.st, "+y,D"),
                new BOpRec(Opcode.st, "-y,D"),
                invalid,

                new BOpRec(Opcode.st, "X,D"),
                new BOpRec(Opcode.st, "+X,D"),
                new BOpRec(Opcode.st, "-X,D"),
                new BOpRec(Opcode.push, "D"),
            };

            var oprecs94 = new OpRec[]
            {
                new BOpRec(Opcode.com, "D"),
                new BOpRec(Opcode.neg, "D"),
                new BOpRec(Opcode.swap, "D"),
                new BOpRec(Opcode.inc, "D"),

                invalid,
                new BOpRec(Opcode.asr, "D"),
                new BOpRec(Opcode.lsr, "D"),
                new BOpRec(Opcode.ror, "D"),

                new GrpOpRec(4, 5, oprecs94_8),
                new SparseOpRec(4, 5, oprecs94_9),
                new BOpRec(Opcode.dec, "D"),
                new BOpRec(Opcode.des, "i"),

                new BOpRec(Opcode.jmp, "Q"),
                new BOpRec(Opcode.jmp, "Q"),
                new BOpRec(Opcode.call, "Q"),
                new BOpRec(Opcode.call, "Q"),
            };

            var oprecs95 = new OpRec[]
            {
                new BOpRec(Opcode.com, "D"),
                new BOpRec(Opcode.neg, "D"),
                new BOpRec(Opcode.swap, "D"),
                new BOpRec(Opcode.inc, "D"),

                invalid,
                new BOpRec(Opcode.asr, "D"),
                new BOpRec(Opcode.lsr, "D"),
                new BOpRec(Opcode.ror, "D"),

                new GrpOpRec(4, 5, oprecs95_8),
                new SparseOpRec(4, 5, oprecs95_9),
                new BOpRec(Opcode.dec, "D"),
                invalid,

                new BOpRec(Opcode.jmp, "Q"),
                new BOpRec(Opcode.jmp, "Q"),
                new BOpRec(Opcode.call, "Q"),
                new BOpRec(Opcode.call, "Q"),
            };

            var oprecs9 = new OpRec[]
            {
                new GrpOpRec(0, 4, oprecs90),
                new GrpOpRec(0, 4, oprecs90),
                new GrpOpRec(0, 4, oprecs92),
                new GrpOpRec(0, 4, oprecs92),

                new GrpOpRec(0, 4, oprecs94),
                new GrpOpRec(0, 4, oprecs94),   //$TODO: may need a oprecs95 for all the invalid "des"
                new BOpRec(Opcode.adiw, "q,s"),
                new BOpRec(Opcode.sbiw, "q,s"),

                invalid,
                invalid,
                invalid,
                new BOpRec(Opcode.sbis, "g,h"),

                invalid,
                invalid,
                invalid,
                invalid,
            };

            var oprecsB = new OpRec[]
            {
                new BOpRec(Opcode.@in, "D,A"),
                new BOpRec(Opcode.@out, "A,D"),
            };

            var decoders_sbrc = new OpRec[2]
            {
                new BOpRec(Opcode.sbrc, "D,I"),
                invalid,
            };

            var decoders_sbrs = new OpRec[2]
            {
                new BOpRec(Opcode.sbrs, "D,I"),
                invalid,
            };

            var oprecsF = new OpRec[]
            {
                new CondOpRec(),
                new CondOpRec(),
                new CondOpRec(),
                new CondOpRec(),

                new CondOpRec(),
                new CondOpRec(),
                new CondOpRec(),
                new CondOpRec(),

                invalid,
                invalid,
                invalid,
                invalid,

                new GrpOpRec(3, 1, decoders_sbrc),
                new GrpOpRec(3, 1, decoders_sbrc),
                new GrpOpRec(3, 1, decoders_sbrs),
                new GrpOpRec(3, 1, decoders_sbrs),
            };

            oprecs = new OpRec[]
            {
                new GrpOpRec(8, 4, oprecs0),
                new GrpOpRec(10, 2, oprecs1),
                new GrpOpRec(10, 2, oprecs2),
                new BOpRec(Opcode.cpi, "d,B"),

                new BOpRec(Opcode.sbci, "d,B"),
                new BOpRec(Opcode.subi, "d,B"),
                new BOpRec(Opcode.ori, "d,B"),
                new BOpRec(Opcode.andi, "d,B"),

                new GrpOpRec(9, 3, oprecs8),
                new GrpOpRec(8, 4, oprecs9),
                invalid,
                new GrpOpRec(0xB, 1, oprecsB),

                new BOpRec(Opcode.rjmp, "J", InstrClass.Transfer),
                new BOpRec(Opcode.rcall, "J", InstrClass.Transfer | InstrClass.Call),
                new BOpRec(Opcode.ldi, "d,K"),
                new GrpOpRec(8, 4, oprecsF),
            };
        }
        static XtensaDisassembler()
        {
            b4const = new int[16]
            {
                -1, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
            };

            b4constu = new int[16]
            {
                0x8000,
                0x10000,
                0x2,
                0x3,
                0x4,
                0x5,
                0x6,
                0x7,

                0x8,
                0xA,
                0xC,
                0x10,
                0x20,
                0x40,
                0x80,
                0x100,
            };

            var reserved = new OpRec(Opcodes.reserved, "");

            var oprecLSCX = new Op1Rec(
                new OpRec(Opcodes.lsx, "T,Rs,Rr"),
                null,
                reserved,
                reserved,

                null,
                null,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved);

            var oprecLSC4 = new Op2Rec(
                new OpRec(Opcodes.l32e, "Rt,Rs,e"),
                reserved,
                reserved,
                reserved,

                new OpRec(Opcodes.s32e, "Rt,Rs,e"),
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved);

            var oprecFP0 = new Op2Rec(
                new OpRec(Opcodes.add_s, "Fr,Fs,Ft"),
                new OpRec(Opcodes.sub_s, "Fr,Fs,Ft"),
                new OpRec(Opcodes.mul_s, "Fr,Fs,Ft"),
                reserved,

                null,
                null,
                null,
                null,

                null,
                null,
                null,
                new OpRec(Opcodes.floor_s, "Rr,Fs,It"),

                null,
                null,
                null,
                null);

            var oprecFP1 = new Op2Rec(
                reserved,
                null,
                null,
                new OpRec(Opcodes.ueq_s, "Br,Fs,Ft"),

                null,
                null,
                null,
                null,

                new OpRec(Opcodes.moveqz_s, "Fr,Fs,Rt"),
                null,
                null,
                null,

                null,
                null,
                reserved,
                reserved);

            var oprecJR = new n_Rec(
                new OpRec(Opcodes.ret, ""),
                null,
                new OpRec(Opcodes.jx, "Rs"),
                reserved);

            var oprecCALLX = new n_Rec(
                new OpRec(Opcodes.callx0, "Rs"),
                new OpRec(Opcodes.callx4, "Rs"),
                new OpRec(Opcodes.callx8, "Rs"),
                new OpRec(Opcodes.callx12, "Rs"));

            var oprecSNM0 = new m_Rec(
                new OpRec(Opcodes.ill, ""),
                null,
                oprecJR,
                oprecCALLX);

            var oprecSYNC = new t_Rec(
                new OpRec(Opcodes.isync, ""),
                null,
                null,
                null,

                null,
                null,
                null,
                null,

                null,
                null,
                null,
                null,

                new OpRec(Opcodes.memw, ""),
                null,
                null,
                null);

            var oprecRFET = new s_Rec(
                new OpRec(Opcodes.rfe, ""),
                null,
                null,
                reserved,

                null,
                null,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved);

            var oprecRFEI = new t_Rec(
                oprecRFET,
                new OpRec(Opcodes.rfi, "Is"),
                null,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved);


            var oprecBZ = new m_Rec(
                new OpRec_bz(Opcodes.beqz),
                new OpRec_bz(Opcodes.bnez),
                new OpRec_bz(Opcodes.bltz),
                new OpRec_bz(Opcodes.bgez));

            var oprecBI0 = new m_Rec(
                new OpRec(Opcodes.beqi, "Rs,bs,j"),
                new OpRec(Opcodes.bnei, "Rs,bs,j"),
                new OpRec(Opcodes.blti, "Rs,bs,j"),
                new OpRec(Opcodes.bgei, "Rs,bs,j"));

            var oprecBI1 = new m_Rec(
                null,
                null,
                new OpRec(Opcodes.bltui, "Rs,bu,j"),
                new OpRec(Opcodes.bgeui, "Rs,bu,j"));

            var oprecSI = new n_Rec(
                new OpRec(Opcodes.j, "J"),
                oprecBZ,
                oprecBI0,
                oprecBI1);

            var oprecB = new r_Rec(
                new OpRec(Opcodes.bnone, "Rs,Rt,j"),
                new OpRec(Opcodes.beq, "Rs,Rt,j"),
                new OpRec(Opcodes.blt, "Rs,Rt,j"),
                new OpRec(Opcodes.bltu, "Rs,Rt,j"),

                new OpRec(Opcodes.ball, "Rs,Rt,j"),
                new OpRec(Opcodes.bbc, "Rs,Rt,j"),
                new OpRec_bbxi(Opcodes.bbci),
                new OpRec_bbxi(Opcodes.bbci),

                new OpRec(Opcodes.bany, "Rs,Rt,j"),
                new OpRec(Opcodes.bne, "Rs,Rt,j"),
                new OpRec(Opcodes.bge, "Rs,Rt,j"),
                new OpRec(Opcodes.bgeu, "Rs,Rt,j"),

                new OpRec(Opcodes.bnall, "Rs,Rt,j"),
                new OpRec(Opcodes.bbs, "Rs,Rt,j"),
                new OpRec_bbxi(Opcodes.bbsi),
                new OpRec_bbxi(Opcodes.bbsi));

            var oprecST0 = new r_Rec(
                oprecSNM0,
                null,
                oprecSYNC,
                oprecRFEI,

                new OpRec(Opcodes.@break, "Is,It"),
                null,
                new OpRec(Opcodes.rsil, "Rt,Is"),
                null,

                null,
                null,
                null,
                null,

                null,
                null,
                null,
                null);

            var oprecST1 = new r_Rec(
                new OpRec(Opcodes.ssr, "Rs"),
                new OpRec(Opcodes.ssl, "Rs"),
                new OpRec(Opcodes.ssa8l, "Rs"),
                null,

                new OpRec(Opcodes.ssai, "II"),
                reserved,
                null,
                null,

                null,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                new OpRec(Opcodes.nsa, "Rt,Rs"),
                new OpRec(Opcodes.nsau, "Rt,Rs"));

            var oprecST2 = new t_Rec(
                new OpRecMovi_n(),
                new OpRecMovi_n(),
                new OpRecMovi_n(),
                new OpRecMovi_n(),

                new OpRecMovi_n(),
                new OpRecMovi_n(),
                new OpRecMovi_n(),
                new OpRecMovi_n(),

                new OpRecBeqxx_n(Opcodes.beqz_n),
                new OpRecBeqxx_n(Opcodes.beqz_n),
                new OpRecBeqxx_n(Opcodes.beqz_n),
                new OpRecBeqxx_n(Opcodes.beqz_n),

                new OpRecBeqxx_n(Opcodes.bnez_n),
                new OpRecBeqxx_n(Opcodes.bnez_n),
                new OpRecBeqxx_n(Opcodes.bnez_n),
                new OpRecBeqxx_n(Opcodes.bnez_n));

            var oprecS3 = new t_Rec(
                new OpRec(Opcodes.ret_n, "", true),
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved);

            var oprecST3 = new r_Rec(
                new OpRec(Opcodes.mov_n, "Rt,Rs", true),
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                oprecS3);

            var oprecRT0 = new s_Rec(
                new OpRec(Opcodes.neg, "Rr,Rt"),
                new OpRec(Opcodes.abs, "Rr,Rt"),
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved);

            var oprecRST0 = new Op2Rec(
                oprecST0,
                new OpRec(Opcodes.and, "Rr,Rs,Rt"),
                new OpRec(Opcodes.or, "Rr,Rs,Rt"),
                new OpRec(Opcodes.xor, "Rr,Rs,Rt"),

                oprecST1,
                null,
                oprecRT0,
                reserved,

                new OpRec(Opcodes.add, "Rr,Rs,Rt"),
                new OpRec(Opcodes.addx2, "Rr,Rs,Rt"),
                new OpRec(Opcodes.addx4, "Rr,Rs,Rt"),
                new OpRec(Opcodes.addx8, "Rr,Rs,Rt"),

                new OpRec(Opcodes.sub, "Rr,Rs,Rt"),
                new OpRec(Opcodes.subx2, "Rr,Rs,Rt"),
                new OpRec(Opcodes.subx4, "Rr,Rs,Rt"),
                new OpRec(Opcodes.subx8, "Rr,Rs,Rt"));

            var oprecIMP = new r_Rec(
                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                new OpRec(Opcodes.ldpte, ""));       //$TODO: doesn't appear to be documented

            var oprecRST1 = new Op2Rec(
                new OpRec(Opcodes.slli, "Rr,Rs,IS"),
                new OpRec(Opcodes.slli, "Rr,Rs,IS"),
                new OpRec(Opcodes.srai, "Rr,Rt,IR"),
                new OpRec(Opcodes.srai, "Rr,Rt,IR"),

                new OpRec(Opcodes.srli, "Rr,Rt,Is"),
                reserved,
                null,
                null,

                new OpRec(Opcodes.src, "Rr,Rs,Rt"),
                new OpRec(Opcodes.srl, "Rr,Rt"),
                new OpRec(Opcodes.sll, "Rr,Rs"),
                new OpRec(Opcodes.sra, "Rr,Rs"),

                new OpRec(Opcodes.mul16u, "Rr,Rs,Rt"),
                new OpRec(Opcodes.mul16s, "Rr,Rs,Rt"),
                reserved,
                oprecIMP);

            var oprecRST2 = new Op2Rec(
                new OpRec(Opcodes.andb, "Br,Bs,Bt"),
                new OpRec(Opcodes.andbc, "Br,Bs,Bt"),
                new OpRec(Opcodes.orb, "Br,Bs,Bt"),
                new OpRec(Opcodes.orbc, "Br,Bs,Bt"),

                new OpRec(Opcodes.xorb, "Br,Bs,Bt"),
                reserved,
                reserved,
                reserved,

                new OpRec(Opcodes.mull, "Rr,Rs,Rt"),
                reserved,
                null,
                null,

                new OpRec(Opcodes.quou, "Rr,Rs,Rt"),
                new OpRec(Opcodes.quos, "Rr,Rs,Rt"),
                new OpRec(Opcodes.remu, "Rr,Rs,Rt"),
                new OpRec(Opcodes.rems, "Rr,Rs,Rt"));

            var oprecRST3 = new Op2Rec(
                new OpRec(Opcodes.rsr, "Rt,S"),
                new OpRec(Opcodes.wsr, "Rt,S"),
                null,
                null,

                new OpRec(Opcodes.min, "Rr,Rs,Rt"),
                new OpRec(Opcodes.max, "Rr,Rs,Rt"),
                new OpRec(Opcodes.minu, "Rr,Rs,Rt"),
                new OpRec(Opcodes.maxu, "Rr,Rs,Rt"),

                new OpRec(Opcodes.moveqz, "Rr,Rs,Rt"),
                new OpRec(Opcodes.movnez, "Rr,Rs,Rt"),
                new OpRec(Opcodes.movltz, "Rr,Rs,Rt"),
                new OpRec(Opcodes.movgez, "Rr,Rs,Rt"),

                null,
                null,
                null,
                null);

            var oprecQRST = new Op1Rec(
                oprecRST0,
                oprecRST1,
                oprecRST2,
                oprecRST3,

                new ExtuiOpRec(),
                new ExtuiOpRec(),
                new OpRec(Opcodes.cust0, ""),
                new OpRec(Opcodes.cust1, ""),

                oprecLSCX,
                oprecLSC4,
                oprecFP0,
                oprecFP1,

                new OpRec(Opcodes.reserved, ""),
                new OpRec(Opcodes.reserved, ""),
                new OpRec(Opcodes.reserved, ""),
                new OpRec(Opcodes.reserved, ""));

            var oprecLSAI = new r_Rec(
                new OpRec(Opcodes.l8ui, "Rt,Rs,80"),
                new OpRec(Opcodes.l16ui, "Rt,Rs,81"),
                new OpRec(Opcodes.l32i, "Rt,Rs,82"),
                reserved,

                new OpRec(Opcodes.s8i, "Rt,Rs,80"),
                new OpRec(Opcodes.s16i, "Rt,Rs,81"),
                new OpRec(Opcodes.s32i, "Rt,Rs,82"),
                null,

                null,
                new OpRec(Opcodes.l16si, "Rt,Rs,81"),
                new OpRec(Opcodes.movi, "Rt,i"),
                null,

                new OpRec(Opcodes.addi, "Rt,Rs,m0"),
                new OpRec(Opcodes.addmi, "Rt,Rs,m8"),
                null,
                new OpRec(Opcodes.s32ri, "Rt,Rs,82"));

            var oprecLSCI = new r_Rec(
                reserved,
                reserved,
                reserved,
                reserved,

                new OpRec(Opcodes.ssi, "Ft,Rs,82"),
                reserved,
                reserved,
                reserved,

                new OpRec(Opcodes.lsiu, "Ft,Rs,82"),
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved);

            var oprecMACID = new Op1Rec(
                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                null,
                null,
                null,
                null,

                reserved,
                reserved,
                reserved,
                reserved);
            var oprecMACDD = new Op1Rec(
                reserved,
                reserved,
                reserved,
                reserved,

                null,
                null,
                null,
                null,

                null,
                null,
                null,
                null,

                null,
                null,
                null,
                null);

            var oprecMACC = new Op1Rec(
                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved);

            var oprecMAC16 = new Op2Rec(
                oprecMACID,
                null,
                oprecMACDD,
                null,

                null,
                null,
                null,
                null,

                null,
                oprecMACC,
                reserved,
                reserved,

                reserved,
                reserved,
                reserved,
                reserved);

            var oprecCALLN = new n_Rec(
                new OpRec(Opcodes.call0, "c"),
                new OpRec(Opcodes.call4, "c"),
                new OpRec(Opcodes.call8, "c"),
                new OpRec(Opcodes.call12, "c"));

            oprecs = new OpRecBase[]
            {
                oprecQRST,
                new OpRec(Opcodes.l32r, "Rt,p"),
                oprecLSAI,
                oprecLSCI,

                oprecMAC16,
                oprecCALLN,
                oprecSI,
                oprecB,

                new OpRec(Opcodes.l32i_n, "Rt,Rs,42", true),
                new OpRec(Opcodes.s32i_n, "Rt,Rs,42", true),
                new OpRec(Opcodes.add_n, "Rr,Rs,Rt", true),
                new OpRec(Opcodes.addi_n, "Rr,Rs,a", true),

                oprecST2,
                oprecST3,
                reserved,
                reserved,
            };
        }
Beispiel #6
0
        static RiscVDisassembler()
        {
            var loads = new OpRec[]
            {
                new WOpRec(Opcode.lb, "d,1,Ls"),
                new WOpRec(Opcode.lh, "d,1,Ls"),
                new WOpRec(Opcode.lw, "d,1,Ls"),
                new WOpRec(Opcode.ld, "d,1,Ls"),

                new WOpRec(Opcode.lbu, "d,1,Ls"),
                new WOpRec(Opcode.lhu, "d,1,Ls"),
                new WOpRec(Opcode.lwu, "d,1,Ls"),
                new WOpRec(Opcode.invalid, ""),
            };

            var fploads = new OpRec[]
            {
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.flw, "Fd,1,Ls"),
                new WOpRec(Opcode.invalid, ""),

                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
            };

            var stores = new OpRec[]
            {
                new WOpRec(Opcode.sb, "2,1,Ss"),
                new WOpRec(Opcode.sh, "2,1,Ss"),
                new WOpRec(Opcode.sw, "2,1,Ss"),
                new WOpRec(Opcode.sd, "2,1,Ss"),

                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
            };

            var op = new OpRec[]
            {
                new ShiftOpRec("d,1,2", Opcode.add, Opcode.sub),
                new WOpRec(Opcode.sll, "d,1,2"),
                new WOpRec(Opcode.slt, "d,1,2"),
                new WOpRec(Opcode.sltu, "d,1,2"),

                new WOpRec(Opcode.xor, "d,1,2"),
                new ShiftOpRec("d,1,2", Opcode.srl, Opcode.sra),
                new WOpRec(Opcode.or, "d,1,2"),
                new WOpRec(Opcode.and, "d,1,2"),
            };

            var opimm = new OpRec[]
            {
                new WOpRec(Opcode.addi, "d,1,i"),
                new ShiftOpRec("d,1,z", Opcode.slli, Opcode.invalid),
                new WOpRec(Opcode.slti, "d,1,i"),
                new WOpRec(Opcode.sltiu, "d,1,i"),

                new WOpRec(Opcode.xori, "d,1,i"),
                new ShiftOpRec("d,1,z", Opcode.srli, Opcode.srai),
                new WOpRec(Opcode.ori, "d,1,i"),
                new WOpRec(Opcode.andi, "d,1,i"),
            };

            var opimm32 = new OpRec[]
            {
                new WOpRec(Opcode.addiw, "d,1,i"),
                new ShiftOpRec("d,1,Z", Opcode.slliw, Opcode.invalid),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),

                new WOpRec(Opcode.invalid, ""),
                new ShiftOpRec("d,1,Z", Opcode.srliw, Opcode.sraiw),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
            };

            var op32 = new OpRec[]
            {
                new ShiftOpRec("d,1,2", Opcode.addw, Opcode.subw),
                new ShiftOpRec("d,1,2", Opcode.sllw, Opcode.invalid),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),

                new WOpRec(Opcode.invalid, ""),
                new ShiftOpRec("d,1,2", Opcode.srlw, Opcode.sraw),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
            };

            var opfp = new Dictionary <int, OpRec>
            {
                { 0x00, new FpuOpRec(Opcode.fadd_s, "Fd,F1,F2") },
                { 0x01, new FpuOpRec(Opcode.fadd_d, "Fd,F1,F2") },
                { 0x21, new FpuOpRec(Opcode.fcvt_d_s, "Fd,F1") },
                { 0x50, new SparseMaskOpRec(12, 7, new Dictionary <int, OpRec>
                    {
                        { 2, new WOpRec(Opcode.feq_s, "d,F1,F2") }
                    }) },
                { 0x71, new FpuOpRec(Opcode.fmv_d_x, "Fd,1") },
                { 0x78, new FpuOpRec(Opcode.fmv_s_x, "Fd,1") },
            };

            var branches = new OpRec[]
            {
                new WOpRec(Opcode.beq, InstrClass.ConditionalTransfer, "1,2,B"),
                new WOpRec(Opcode.bne, InstrClass.ConditionalTransfer, "1,2,B"),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),

                new WOpRec(Opcode.blt, InstrClass.ConditionalTransfer, "1,2,B"),
                new WOpRec(Opcode.bge, InstrClass.ConditionalTransfer, "1,2,B"),
                new WOpRec(Opcode.bltu, InstrClass.ConditionalTransfer, "1,2,B"),
                new WOpRec(Opcode.bgeu, InstrClass.ConditionalTransfer, "1,2,B"),
            };

            wideOpRecs = new OpRec[]
            {
                // 00
                new MaskOpRec(12, 7, loads),
                new MaskOpRec(12, 7, fploads),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),

                new MaskOpRec(12, 7, opimm),
                new WOpRec(Opcode.auipc, "d,Iu"),
                new MaskOpRec(12, 7, opimm32),
                new WOpRec(Opcode.invalid, ""),

                new MaskOpRec(12, 7, stores),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),

                new MaskOpRec(12, 7, op),
                new WOpRec(Opcode.lui, "d,Iu"),
                new MaskOpRec(12, 7, op32),
                new WOpRec(Opcode.invalid, ""),

                // 10
                new FpuOpRec(Opcode.fmadd_s, "Fd,F1,F2,F3"),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),

                new SparseMaskOpRec(25, 0x7F, opfp),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),

                new MaskOpRec(12, 7, branches),
                new WOpRec(Opcode.jalr, InstrClass.Transfer, "d,1,i"),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.jal, InstrClass.Transfer | InstrClass.Call, "d,J"),

                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
                new WOpRec(Opcode.invalid, ""),
            };

            compressed0 = new OpRec[]
            {
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),

                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
            };

            compressed1 = new OpRec[]
            {
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),

                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
            };

            compressed2 = new OpRec[]
            {
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),

                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
                new COpRec(Opcode.invalid, ""),
            };

            opRecs = new OpRec[]
            {
                new MaskOpRec(0x13, 7, compressed0),
                new MaskOpRec(0x13, 7, compressed1),
                new MaskOpRec(0x13, 7, compressed2),
                new WideOpRec()
            };
        }
Beispiel #7
0
 public Alternative64OpRec(OpRec oprec32, OpRec oprec64)
 {
     this.oprec32 = oprec32;
     this.oprec64 = oprec64;
 }