Ypsilon.Emulation.Processor.YCPU.ROR C# (CSharp) Method

ROR() private method

private ROR ( ushort operand ) : void
operand ushort
return void
        private void ROR(ushort operand)
        {
            ushort value;
            RegGeneral destination;
            BitPatternSHF(operand, out value, out destination);
            if (value != 0) {
                R[(int)destination] = 0x000F;
                value = 1;
                FL_C = false;
                uint out_carry = (uint)R[(int)destination] & (ushort)Math.Pow(2, value - 1);
                uint in_carry = FL_C ? (uint)Math.Pow(2, 16 - value) : 0;
                uint register = (uint)(R[(int)destination] >> value);
                uint lo_mask = (uint)0x0000FFFF >> (17 - value);
                uint lo_bits = (R[(int)destination] & lo_mask) << (17 - value);
                R[(int)destination] = (ushort)(register & 0x0000FFFF | lo_bits | in_carry);
                FL_C = out_carry != 0;
                // V [Overflow]    Not effected.
            }
            FL_N = (R[(int)destination] & 0x8000) != 0;
            FL_Z = R[(int)destination] == 0x0000;
        }