Exemple #1
0
        public void RotateRightThroughCarryThrowsNotImplementedException()
        {
            var operand1 = Constants.Operand1;
            var operand2 = Constants.Operand2;
            var result   = new Data();

            BitShiftOperations.RotateRightThroughCarry(result, operand1, operand2);
        }
        public void PerformOperation()
        {
            if (Operand1 == null)
            {
                throw new InvalidOperationException($"Can't perform operation if {nameof(Operand1)} is null");
            }

            if (Operand2 == null)
            {
                throw new InvalidOperationException($"Can't perform operation if {nameof(Operand2)} is null");
            }

            if (Operator == AluOperator.Undefined)
            {
                throw new InvalidOperationException($"Can't perform operation if {nameof(Operator)} is undefined");
            }

            Result = new Data();
            switch (Operator)
            {
            case AluOperator.Add:
                ArithmeticOperations.Add(Result, Operand1, Operand2);
                break;

            case AluOperator.Subtract:
                ArithmeticOperations.Subtract(Result, Operand1, Operand2);
                break;

            case AluOperator.And:
                BitWiseOperations.And(Result, Operand1, Operand2);
                break;

            case AluOperator.Or:
                BitWiseOperations.Or(Result, Operand1, Operand2);
                break;

            case AluOperator.ExclusiveOr:
                BitWiseOperations.ExclusiveOr(Result, Operand1, Operand2);
                break;

            case AluOperator.Negate:
                BitWiseOperations.Negate(Result, Operand1);
                break;

            case AluOperator.ArithmeticShiftRight:
                BitShiftOperations.ArithmeticShiftRight(Result, Operand1, Operand2);
                break;

            case AluOperator.ArithmeticShiftLeft:
                BitShiftOperations.ArithmeticShiftLeft(Result, Operand1, Operand2);
                break;

            case AluOperator.LogicalShiftRight:
                BitShiftOperations.LogicalShiftRight(Result, Operand1, Operand2);
                break;

            case AluOperator.LogicalShiftLeft:
                BitShiftOperations.LogicalShiftLeft(Result, Operand1, Operand2);
                break;

            case AluOperator.RotateRight:
                BitShiftOperations.RotateRight(Result, Operand1, Operand2);
                break;

            case AluOperator.RotateLeft:
                BitShiftOperations.RotateLeft(Result, Operand1, Operand2);
                break;

            case AluOperator.RotateRightThroughCarry:
                BitShiftOperations.RotateRightThroughCarry(Result, Operand1, Operand2);
                break;

            case AluOperator.RotateLeftThroughCarry:
                BitShiftOperations.RotateLeftThroughCarry(Result, Operand1, Operand2);
                break;
            }
        }