Exemplo n.º 1
0
        public void Test6()
        {
            // Arrange
            var byte2 = new Byte2(27);

            // Act
            var output = UnaryArithmeticLogicUnit.Do(false, true, byte2);

            // Assert
            output.ToUInt16().Should().Be(65508);
        }
Exemplo n.º 2
0
        public void Test9()
        {
            // Arrange
            var byte2 = new Byte2("1111111111111111");

            // Act
            var output = UnaryArithmeticLogicUnit.Do(false, false, byte2);

            // Assert
            output.ToString().Should().Be("1111111111111111");
        }
Exemplo n.º 3
0
        public void Test3()
        {
            // Arrange
            var byte2 = new Byte2(0);

            // Act
            var output = UnaryArithmeticLogicUnit.Do(true, false, byte2);

            // Assert
            output.ToInt16().Should().Be(0);
        }
        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);
        }