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

ROL() private method

private ROL ( ushort operand ) : void
operand ushort
return void
        private void ROL(ushort operand)
        {
            ushort value;
            RegGeneral destination;
            BitPatternSHF(operand, out value, out destination);
            if (value != 0) {
                uint out_carry = (uint)R[(int)destination] & (ushort)Math.Pow(2, 16 - value);
                uint in_carry = FL_C ? (uint)Math.Pow(2, value - 1) : 0;
                uint register = (uint)(R[(int)destination] << value);
                uint hi_mask = 0xFFFF0000 ^ (uint)Math.Pow(2, 15 + value);
                R[(int)destination] = (ushort)(register & 0x0000FFFF | (register & hi_mask) >> 16 | in_carry);
                FL_C = out_carry != 0;

                // V [Overflow]    Not effected.
            }
            FL_N = (R[(int)destination] & 0x8000) != 0;
            FL_Z = R[(int)destination] == 0x0000;
        }