public override void Write(OnesCompliment value) { // only store lower 12 bits var maskedBits = value & 0xFFF; WriteRaw(maskedBits); }
/// <summary> /// 15-bit writes are overflow corrected from 16-bit values /// </summary> /// <param name="value"></param> public virtual void Write(OnesCompliment value) { // in case there is an overflow, correct it var correctedValue = OverflowCorrect(value.NativeValue); // sign extend, since we store all values as 16-bit correctedValue = SignExtend(correctedValue); WriteRaw(correctedValue); }
public override void Write(OnesCompliment value) { // in case this is coming from a 16-bit register, overflow correct it, but we only want the 15 bit value var correctedValue = OverflowCorrect(value.NativeValue) & 0x7FFF; // preserve MSBs and OR with shifted bits var bits = (correctedValue & 0x4000) | (correctedValue >> 1); // write the shifted value into memory, but sign extended to fill 16 bits WriteRaw(SignExtend((ushort)bits)); }
public override void Write(OnesCompliment value) { // get bit position 1, and move it to position 15 var leastSignificateBit = (value & 0x1) << 14; // 15 bit register, so shift right 1, get the lower 14 bits, and add the wrap around bit var bits = ((value.NativeValue >> 1) & 0x3FFF) | leastSignificateBit; // write the sign-extended cycled value into memory WriteRaw(SignExtend((ushort)bits)); }
public override void Write(OnesCompliment value) { var maskedValue = value & 0x7C00; // read current value of bb register // use mask to get EB value var eb = ReadRaw(0x6) & 0x0007; // write new bb value WriteRaw(maskedValue | eb, 0x6); // can only set the 5 bits for the fixed memory bank selection WriteRaw(maskedValue); }
public override void Write(OnesCompliment value) { // mask values, since they are the only ones that can be set var eb = value.NativeValue & 0x0007; var fb = value.NativeValue & 0x7C00; // write values to eb and fb register // shift eb values left by 8 WriteRaw(eb << 8, 0x3); WriteRaw(fb, 0x4); // write combined, masked value WriteRaw(eb | fb); }
public override void Write(OnesCompliment value) { var maskedValue = value & 0x0700; // read current value of bb register // use mask to get FB value var fb = ReadRaw(0x6) & 0x7C00; // write new bb value (fb and right shifted eb value) WriteRaw((maskedValue >> 8) | fb, 0x6); // can only set the 3 bits for the erasable memory bank selection WriteRaw(maskedValue); }
public void Add_Double() { // arrange Memory[0x000] = new OnesCompliment(2); // insert instructions Memory.LoadFixedRom(new ushort[] { 0x06000 | 0x000 }); // act - run the instructions CPU.Execute(); // assert CustomAssert.AreEqual(4, Memory[0x000]); }
public void CountCompareSkip_PositiveOverflowAnd0() { // arrange // set A to 0 with positive overflow Memory[0x000] = new OnesCompliment(0x4000 | 0); // insert instructions Memory.LoadFixedRom(new ushort[] { Instruction(0x01, 0x000) // CCS A }); // act CPU.Execute(); // assert // check that A contains value without overflow CustomAssert.AreEqual(0x3FFF, Memory[0x0]); // check that program counter advanced 1 CustomAssert.AreEqual(0x801, Memory[0x05]); }
public DoublePrecision(OnesCompliment most, OnesCompliment least) { MostSignificantWord = most; LeastSignificantWord = least; }
public static void AreEqual(int expected, OnesCompliment actual) { Assert.AreEqual((ushort)expected, actual.NativeValue); }
public static void AreEqual(OnesCompliment expected, OnesCompliment actual) { Assert.AreEqual(expected.NativeValue, actual.NativeValue); }
public void Add(OnesCompliment value) { var sum = value + Read(); Write(sum); }
/// <summary> /// cannot write to fixed memory /// </summary> /// <param name="value"></param> public override void Write(OnesCompliment value) { //throw new InvalidOperationException("Cannot write to a fixed memory location"); }
/// <summary> /// Write the full 16 bits into memory without overflow correction /// </summary> /// <param name="value"></param> public override void Write(OnesCompliment value) { WriteRaw(value.NativeValue); }