Example #1
0
        public IInstruction ReadInstruction(uint inst)
        {
            if (!Enum.IsDefined(typeof(Opcode), inst >> 26))
            {
                return(UndefinedInstruction.FromInteger(inst));
            }
            var opcode = (Opcode)(inst >> 26);

            switch (opcode)
            {
            case Opcode.RType:
                var rIns = RTypeInstruction.FromInteger(inst);
                rIns.Executor = RTypeExecutors[rIns.Function];
                return(rIns);

            case Opcode.Jump:
            case Opcode.JumpAndLink:
                var jIns = JTypeInstruction.FromInteger(inst);
                jIns.Executor = JTypeExecutors[jIns.JumpType];
                return(jIns);

            case Opcode.CoProcessor:
                var coIns = CoProcessorInstruction.FromInteger(inst);
                coIns.Executor = CoProcessorExecutors[coIns.Format];
                return(coIns);

            default:
                var iIns = ITypeInstruction.FromInteger(inst);
                iIns.Executor = ITypeExecutors[iIns.Opcode];
                return(iIns);
            }
        }
Example #2
0
        public static RTypeInstruction FromInteger(uint v)
        {
            var rtype = new RTypeInstruction()
            {
                Function = (RTypeFunction)(v & 0x3f),
                Sa       = ((v >> 6) & 0x1f),
                Rd       = ((v >> 11) & 0x1f),
                Rt       = ((v >> 16) & 0x1f),
                Rs       = ((v >> 21) & 0x1f),
            };

            return(rtype);
        }