private static void STA(CPU cpu) //Store Address { //Result stores orignal core storage word with bits 21-35 replaced by the //accumulator 21-35 bits string fromCore = cpu.GetCoreStorageWord(cpu.IndexedAddress).Substring(0, 21); string fromAccum = cpu.AccumulatorReg.Bits_SignTo35.Substring(21, 15); string result = fromCore + fromAccum; cpu.SetCoreStorageWord(result, cpu.IndexedAddress); //Increment IRC cpu.InstructionCounter.Increment(1); }
/// <summary> /// Floating Subtract 7-11 FSB Y +0302 /// </summary> /// <param name="cpu"></param> private static void FSB(CPU cpu) { FloatingPointNumber fromCore = new FloatingPointNumber(cpu.GetCoreStorageWord(cpu.IndexedAddress)); FloatingPointNumber fromAccum = new FloatingPointNumber(cpu.AccumulatorReg.Bits_SignTo35); fromAccum.DecimalValue = fromAccum.DecimalValue - fromCore.DecimalValue; cpu.AccumulatorReg.Bits_SignTo35 = fromAccum.Value; cpu.AccumulatorReg.PBit = "0"; cpu.AccumulatorReg.QBit = "0"; cpu.MQReg.Value = fromAccum.Value; cpu.InstructionCounter.Increment(1); }
/// <summary> /// This instruction algebraically subtracts the C(Y) from the C(AC) and replaces the C(AC) with /// this difference. The C(Y) are unchanged. Ac overflow is possible /// </summary> /// <param name="cpu"></param> private static void SUB(CPU cpu) { long fromCore = Converter.ConvertToInt(cpu.GetCoreStorageWord(cpu.IndexedAddress)); long fromAccum = Converter.ConvertToInt(cpu.AccumulatorReg.Bits_SignTo35); long result = fromAccum - fromCore; string newWord = Converter.ConvertToBinary(result, 36); if (newWord.Length > 36) { cpu.AccumOverflowIndicator = true; cpu.AccumulatorReg.Bits_SignTo35 = newWord.Substring(0, 36); } else { cpu.AccumulatorReg.Bits_SignTo35 = newWord; } cpu.InstructionCounter.Increment(1); }
/// <summary> /// Multiply ///20 MPY Y +0200 ///This instruction multiplies the c (Y) by the c(MQ) . The 3 5 most significant bits of the 70-bit product /// replace the C(AC)1.35 and the 3 5 least significant bits replace the c (MQ) !_35. The Q and P bits are /// cleared. The sign of the AC is the algebraic sign of the product. The sign of the MQ agrees with the sign /// of the AC. /// Placing of the binary point in the factors is com¬pletely arbitrary. A simple familiar rule to remember /// with regard to placing the binary point in the result¬ing product follows. /// RULE: Add the number of binary bits to the right of the binary point in the first factor to the number /// of binary bits to the right of the binary point in the second factor. This sum is the number of bits /// appear¬ing to the right of the binary point in the product. /// </summary> /// <param name="cpu"></param> private static void MPY(CPU cpu) { long fromCore = Converter.ConvertToInt(cpu.GetCoreStorageWord(cpu.IndexedAddress)); long fromAccum = Converter.ConvertToInt(cpu.AccumulatorReg.Bits_SignTo35); long result = fromCore * fromAccum; //Include one extra bit for the sign string newWord = Converter.ConvertToBinary(result, 71); cpu.AccumulatorReg.PBit = "0"; cpu.AccumulatorReg.QBit = "0"; if (newWord.Length > 71) { cpu.AccumOverflowIndicator = true; } cpu.AccumulatorReg.Bits_SignTo35 = newWord.Substring(0, 36); cpu.MQReg.Value = "0" + newWord.Substring(36, 35); cpu.InstructionCounter.Increment(1); }