public void Test_255_plus_255() { // Arrange var byteA = new Byte2(255); var byteB = new Byte2(255); // Act var byteResult = Arithmetics.AddByte2(byteA, byteB, false); // Assert byteResult.ToInt32().Should().Be(510); }
public void Test_0_plus_32767() { // Arrange var byteA = new Byte2(0); var byteB = new Byte2(32767); // Act var byteResult = Arithmetics.AddByte2(byteA, byteB, false); // Assert byteResult.ToInt32().Should().Be(32767); }
public void Test_0_plus_0() { // Arrange var a = new Byte2(0); var b = new Byte2(0); // Act var byteResult = Arithmetics.AddByte2(a, b, false); // Assert byteResult.ToInt32().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); }