Example #1
0
        public void Test6()
        {
            // Arrange
            var byte2X    = new Byte2(27);
            var byte2Y    = new Byte2(-16);
            var operation = new InstructionDecoder.Operation(false, false, true, true, false, true);

            // Act
            var output = ArithmeticLogicUnit.Do(operation, byte2X, byte2Y);

            // Assert
            output.ToUInt16().Should().Be(65508);
        }
        public static Byte2 Do(InstructionDecoder.Operation operation,
                               Byte2 dataX,
                               Byte2 dataY)
        {
            var transformedDataX = UnaryArithmeticLogicUnit.Do(operation.zx, operation.nx, dataX);

            var transformedDataY = UnaryArithmeticLogicUnit.Do(operation.zy, operation.ny, dataY);

            var and = Gates.And16(transformedDataX, transformedDataY);

            var add = Arithmetics.AddByte2(transformedDataX, transformedDataY, false);

            var selected = Select16.Do(operation.Function, add.Low, and);

            var inverted = Gates.Invert16(selected);

            var output = Select16.Do(operation.NegateOutput, inverted, selected);

            return(output);
        }