Esempio n. 1
0
        }        //calculateMultM

        //32bit multiply instructions (MUL/MLA)
        internal uint ExecuteDataOpMultiply(DataOpMultiplyRaw opHandler, uint opcode, bool setflags)
        {
            //The original code used the masks rd_mask, rn_mask, rm_mask and rs_mask here
            //But the operands are in a strange order so the masks were used in a confusing way.
            //Therefore, we have one of the rare cases where it's better to use magic numbers...
            uint Rm = (opcode) & 0xf;
            uint Rs = (opcode >> 8) & 0xf;
            uint Rd = (opcode >> 16) & 0xf;
            uint Rn = (opcode >> 12) & 0xf;

            uint rs_value = get_reg(Rs);
            uint rm_value = get_reg(Rm);
            uint rn_value = get_reg(Rn);
            //The number of cycles taken for multiplication varies depending
            //on the magnitude of rs_value.
            uint M = calculateMultM(rs_value);

            MultiplyOpResult result = opHandler(rn_value, rs_value, rm_value);

            mGPR[Rd] = result.output_value;

            if (setflags)
            {
                CPSR.set_NZCV((result.output_value & 0x80000000) != 0, result.output_value == 0, CPSR.cf, CPSR.vf);
            }

            return(M + result.cycles);
        }
Esempio n. 2
0
 internal void RegisterDataOpMultiply(DataOpMultiplyRaw opHandler, uint base_opcode, bool supports_setflags, string basename)
 {
     RegisterOpcode(base_opcode, 0xf00fff0f, delegate(uint opcode) { return(ExecuteDataOpMultiply(opHandler, opcode, false)); }, basename);
     if (supports_setflags)
     {
         RegisterOpcode(base_opcode | s_mask, 0xf00fff0f, delegate(uint opcode) { return(ExecuteDataOpMultiply(opHandler, opcode, true)); }, basename + "S");
     }
 }