public void Zero_is_not_less_than_zero() { // Act var equalsZero = Arithmetics.IsLessThanZero(new Byte2(0)); // Assert equalsZero.Should().BeFalse(); }
public void Minvalue_is_less_than_zero() { // Act var equalsZero = Arithmetics.IsLessThanZero(new Byte2(short.MinValue)); // Assert equalsZero.Should().BeTrue(); }
public void Minus_one_is_less_than_zero() { // Act var equalsZero = Arithmetics.IsLessThanZero(new Byte2(-1)); // Assert equalsZero.Should().BeTrue(); }
public void Maxvalue_is_not_less_than_zero() { // Act var byte2 = new Byte2(short.MaxValue); var equalsZero = Arithmetics.IsLessThanZero(byte2); // Assert equalsZero.Should().BeFalse(); }
/// <summary> /// Bit 15 of the input indicates the kind of instruction: /// Bit 15 | Instruction kind /// -------+----------------- /// 0 | data /// 1 | computation /// /// For a data instruction, W(data word) should reflect the input, the a flag should be 1 and all other flags should be 0. /// For a computation instruction, the ci(computation instruction) flag should be 1, W should be 0. All other flags should be mapped from the bits in the input as follows: /// Input Output /// Bit Group flag /// 14 (ignored) - /// 13 (ignored) - /// 12 source sm /// 11 computation zx /// 10 computation nx /// 9 computation zy /// 8 computation ny /// 7 computation f /// 6 computation no /// 5 destination a /// 4 destination d /// 3 destination* a /// 2 condition gt /// 1 condition eq /// 0 condition lt /// </summary> /// <param name="instruction"></param> /// <returns></returns> public static DecodedInstruction Decode(Byte2 instruction) { var isNegative = Arithmetics.IsLessThanZero(instruction); var inverted = Gates.Invert(isNegative); var s = Select16.Do(inverted, new Byte2(0), instruction); var instructionOrZero = Select16.Do(isNegative, new Byte2(0), instruction); return(new DecodedInstruction(isNegative, s.Twelve, new Operation(s.Eleven, s.Ten, s.Nine, s.Eight, s.Seven, s.Six), new Destination(Gates.Or(inverted, s.Five), s.Four, s.Three), new Condition(s.Two, s.One, s.Zero), instructionOrZero)); }
public static bool Evaluate(Condition condition, Byte2 data) { var isLessThanZero = Arithmetics.IsLessThanZero(data); var andIsLessThanZero = Gates.And(condition.LessThanZero, isLessThanZero); var equalsZero = Arithmetics.EqualsZero(data); var andIsEqualToZero = Gates.And(condition.EqualToZero, equalsZero); var isGreaterThanZero = Gates.And(condition.GreaterThanZero, Gates.And(Gates.Invert(isLessThanZero), Gates.Invert(equalsZero))); var lessOrEqual = Gates.Or(andIsLessThanZero, andIsEqualToZero); var lessOrEqualOrGreater = Gates.Or(lessOrEqual, isGreaterThanZero); return(lessOrEqualOrGreater); }