Exemple #1
0
        //--------------------------------------------------------------
        // Purpose: Computes the value of operand2 in data processing instructions
        // Returns: The uint value of the instruction's operand2
        //--------------------------------------------------------------
        private static uint ComputeValue(Data instr)
        {
            op2Type   op2 = Operation.CheckOperand2(instr);
            shiftType shift = Operation.CheckShiftType(instr);
            Memory    registers = Computer.GetCPU().registers;
            uint      value = 0, adjustPC = 0;

            if (instr.RM * 4 == (int)regs.PC || instr.RS * 4 == (int)regs.PC)
            {
                adjustPC = 4;
            }
            switch (op2)
            {
            case op2Type.imm:
                value = BarrelShifter.rotateVal((uint)instr.immediateVal, (byte)shiftType.ror, (uint)instr.rotateVal * 2);
                break;

            case op2Type.reg_imm:
                value = BarrelShifter.rotateVal(registers.ReadWord((uint)instr.RM * 4) + adjustPC, instr.shiftType, instr.shiftVal);
                break;

            case op2Type.reg_reg:
                value = BarrelShifter.rotateVal(registers.ReadWord((uint)instr.RM * 4) + adjustPC, instr.shiftType, registers.ReadWord((uint)instr.RS * 4) + adjustPC);
                break;
            }

            return(value);
        }
Exemple #2
0
        //--------------------------------------------------------------
        // Purpose: Creates disassembly for data processing instructions and sets it
        // Returns: Nothing
        //--------------------------------------------------------------
        private static void SetDataDisassembly(Data instr, uint value, bool isMov)
        {
            op2Type   op2   = Operation.CheckOperand2(instr);
            shiftType shift = Operation.CheckShiftType(instr);

            if (isMov)
            {
                switch (op2)
                {
                case op2Type.imm:
                    instr.disasm.value = Disassembly.ImmMov(instr, value);
                    break;

                case op2Type.reg_imm:
                    instr.disasm.value = Disassembly.RegImmMov(instr);
                    break;

                case op2Type.reg_reg:
                    instr.disasm.value = Disassembly.RegRegMov(instr);
                    break;
                }
            }
            else
            {
                switch (op2)
                {
                case op2Type.imm:
                    instr.disasm.value = Disassembly.ImmData(instr, value);
                    break;

                case op2Type.reg_imm:
                    instr.disasm.value = Disassembly.RegImmData(instr);
                    break;

                case op2Type.reg_reg:
                    instr.disasm.value = Disassembly.RegRegData(instr);
                    break;
                }
            }
        }