示例#1
0
        public static InstructionJ Emit(InstructionMnemonic mnemonic, int address)
        {
            var instruction = ISA.GetInstruction(mnemonic);

            if (instruction.Format != InstructionFormat.J)
            {
                throw new Exception("Wrong instruction type.");
            }
            return(new InstructionJ {
                Instruction = instruction.Instruction,
                OpCode = instruction.OpCode,
                Address = address
            });
        }
示例#2
0
        public static InstructionI Emit(InstructionMnemonic mnemonic,
                                        CpuReg rs, CpuReg rt,
                                        int immediate)
        {
            var instruction = ISA.GetInstruction(mnemonic);

            if (instruction.Format != InstructionFormat.I)
            {
                throw new Exception("Wrong instruction type.");
            }
            return(new InstructionI {
                Instruction = instruction.Instruction,
                OpCode = instruction.OpCode,
                Rs = rs,
                Rt = rt,
                Immediate = immediate
            });
        }
示例#3
0
        public static InstructionR Emit(InstructionMnemonic mnemonic,
                                        CpuReg rs, CpuReg rt, CpuReg rd,
                                        int shamt)
        {
            var instruction = ISA.GetInstruction(mnemonic);

            if (instruction.Format != InstructionFormat.R)
            {
                throw new Exception("Wrong instruction type.");
            }
            return(new InstructionR {
                Instruction = instruction.Instruction,
                OpCode = instruction.OpCode,
                Rs = rs,
                Rt = rt,
                Rd = rd,
                Shamt = shamt,
                Funct = instruction.Function
            });
        }