private void outx(bool IncHL) { OutPort(C.Value, HLM.Value); dec(B); if (IncHL) { HL.Inc(); } else { HL.Dec(); } // See http://www.z80.info/zip/z80-documented.pdf for weird flag behavior int k = L.Value + HLM.Value; if (k > 0xFF) { CF = true; HF = true; } VF = P((k & 0x07) ^ B.Value) != 0; }
IEnumerator StopVehicle(float WaitTime, bool SetNextNode) { CurrentBrakeTorque = MaxTorque; WheelColliders [0].brakeTorque = CurrentBrakeTorque; WheelColliders [1].brakeTorque = CurrentBrakeTorque; WheelColliders [2].brakeTorque = CurrentBrakeTorque; WheelColliders [3].brakeTorque = CurrentBrakeTorque; foreach (GameObject HL in BackLights) //Get every backlight from the backlights array { HL.SetActive(true); //Set them as active } RpcRemoteStopVehicle(CurrentBrakeTorque, true); yield return(new WaitForSeconds(WaitTime)); //Stop time if (SetNextNode == true) { CurrentNode = CurrentNode.GetComponent <PathFinder> ().NextNodes [Random.Range(0, CurrentNode.GetComponent <PathFinder> ().NextNodes.Count)]; //Get the next node } isBraking = false; //We dont need to be braking anymore foreach (GameObject HL in BackLights) //Get every backlight from the backlights array { HL.SetActive(false); //Set them as active } CurrentBrakeTorque = 0f; //Apply the brake torque on all wheels WheelColliders [0].brakeTorque = CurrentBrakeTorque; WheelColliders [1].brakeTorque = CurrentBrakeTorque; WheelColliders [2].brakeTorque = CurrentBrakeTorque; WheelColliders [3].brakeTorque = CurrentBrakeTorque; RpcRemoteStopVehicle(CurrentBrakeTorque, false); }
public bool ReloadWeight() { foreach (var HL in _hiddenLayers) { HL.ReloadWeights(); } _outputLayer.ReloadWeights(); return(true); }
///<Summary> ///<CreatedOn>03/01/2018</CreatedOn> ///<Author>Sunny Bhardwaj</Author> ///<Description>Get HL segment for All</Description> ///</Summary> /// public static HL GetHL(string HL01, string HL02, string HL03, string HL04) { HL HL = new HL(); HL.HL01 = CreateString(HL01.ToString(), (int)SegmentLength.One, (int)SegmentLength.Twelve, '0', true); HL.HL02 = !string.IsNullOrEmpty(HL02) ? CreateString(HL02.ToString(), (int)SegmentLength.One, (int)SegmentLength.Twelve, '0', true) : string.Empty; HL.HL03 = HL03; HL.HL04 = HL04; return(HL); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { HL hlValue = (HL)value; if (!(hlValue.HL4 == "0" || hlValue.HL4 == "1")) { return(new ValidationResult("HL04 can be 0 or 1")); } return(null); }
public void RpcRemoteStopVehicle(float brakeTorque, bool BackLight) //Apply the braketorque and backlights stance to all clients so braking looks better and other clients can see the brake lights on traffic vehicles { WheelColliders [0].brakeTorque = brakeTorque; WheelColliders [1].brakeTorque = brakeTorque; WheelColliders [2].brakeTorque = brakeTorque; WheelColliders [3].brakeTorque = brakeTorque; foreach (GameObject HL in BackLights) //Get every backlight from the backlights array { HL.SetActive(BackLight); //Invert the current stance of the brakelights } }
public override float GetOptimizableCalculationValue(string calculation) { switch (calculation) { case "Health": return BasicStats.Health; case "Holy Light Cast Time": return HL.CastTime(); case "Holy Light HPS": return HL.HPS(); case "Holy Light Time": return RotationHL; case "Flash of Light Cast Time": return FoL.CastTime(); case "Flash of Light HPS": return FoL.HPS(); case "Flash of Light Time": return RotationFoL; } return 0f; }
public override Dictionary <string, string> GetCharacterDisplayCalculationValues() { Dictionary <string, string> dictValues = new Dictionary <string, string>(); dictValues.Add("Status", string.Format("Overall: {0,-10} Fight: {1,-10} Burst: {2,-10}", OverallPoints.ToString("N0"), FightPoints.ToString("N0"), BurstPoints.ToString("N0"))); //Basic Stats dictValues["Health"] = BasicStats.Health.ToString("N00"); dictValues["Stamina"] = BasicStats.Stamina.ToString("N00"); dictValues["Mana"] = BasicStats.Mana.ToString("N00"); dictValues["Intellect"] = BasicStats.Intellect.ToString("N00"); dictValues["Spell Power"] = BasicStats.SpellPower.ToString("N00"); dictValues["Mp5"] = BasicStats.Mp5.ToString("N00"); dictValues["Spell Crit"] = string.Format("{0}%*{1} Crit Rating", (BasicStats.SpellCrit * 100).ToString("N02"), BasicStats.CritRating); dictValues["Spell Haste"] = string.Format("{0}%*{1} Haste Rating", (BasicStats.SpellHaste * 100).ToString("N02"), BasicStats.HasteRating); // Cycle Stats dictValues["Total Healed"] = string.Format("{0} healing", TotalHealed.ToString("N00")); dictValues["Total Mana"] = string.Format("{0} mana", TotalMana.ToString("N00")); dictValues["Average Healing per sec"] = string.Format("{0} hps", AvgHPS.ToString("N00")); dictValues["Average Healing per mana"] = string.Format("{0} hpm", AvgHPM.ToString("N02")); // Rotation Info dictValues["Holy Light Time"] = string.Format("{0} sec", RotationHL.ToString("N1")); dictValues["Flash of Light Time"] = string.Format("{0} sec", RotationFoL.ToString("N1")); dictValues["Holy Shock Time"] = string.Format("{0} sec", RotationHS.ToString("N1")); dictValues["Sacred Shield Time"] = string.Format("{0} sec", RotationSS.ToString("N1")); dictValues["Beacon of Light Time"] = string.Format("{0} sec", RotationBoL.ToString("N1")); dictValues["Judgement Time"] = string.Format("{0} sec", RotationJotP.ToString("N1")); // Healing Breakdown dictValues["Holy Light Healed"] = string.Format("{0} healed", HealedHL.ToString("N00")); dictValues["Flash of Light Healed"] = string.Format("{0} healed", HealedFoL.ToString("N00")); dictValues["Holy Shock Healed"] = string.Format("{0} healed", HealedHS.ToString("N00")); dictValues["Sacred Shield Healed"] = string.Format("{0} healed", HealedSS.ToString("N00")); dictValues["Beacon of Light Healed"] = string.Format("{0} healed", HealedBoL.ToString("N00")); dictValues["Glyph of HL Healed"] = string.Format("{0} healed", HealedGHL.ToString("N00")); dictValues["Other Healed"] = string.Format("{0} healed", HealedOther.ToString("N00")); dictValues["Holy Light"] = "*" + HL.ToString(); dictValues["Flash of Light"] = "*" + FoL.ToString(); dictValues["Holy Shock"] = "*" + HS.ToString(); dictValues["Sacred Shield"] = "*" + SS.ToString(); return(dictValues); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { HL hlValue = (HL)value; if (hlValue.HL4 != "0") { return(new ValidationResult("There should be no child to Patient level")); } string ErrorString = ValidateElement.GetValidation(hlValue.HL1, Element.Required, 1, 12, "HL01") + ValidateElement.GetValidation(hlValue.HL2, Element.Required, 1, 12, "HL02"); if (ErrorString == string.Empty) { return(null); } return(new ValidationResult(ErrorString)); }
private void inx(bool IncHL) { HLM.Value = InPort(C.Value); dec(B); NF = (HLM.Value & 0x80) != 0x00; if (IncHL) { HL.Inc(); } else { HL.Dec(); } // See http://www.z80.info/zip/z80-documented.pdf for weird flag behavior byte c = C.Value; if (IncHL) { c++; } else { c--; } int k = c + HLM.Value; if (k > 0xFF) { CF = true; HF = true; } VF = P((k & 0x07) ^ B.Value) != 0; }
private void cpd() { WZ.Dec(); cpx(); HL.Dec(); }
private void cpi() { WZ.Inc(); cpx(); HL.Inc(); }
/// <summary> /// デジタル出力値をセット /// </summary> /// <param name="pin">ピン番号</param> /// <param name="digital">デジタル出力値</param> public void setPinValue(byte pin, HL digital) { byte[] byteWrite = new byte[8]; byteWrite[0] = deviceAddress; byteWrite[1] = 0x06; byteWrite[2] = HREGIST_PIN_DATA; byteWrite[3] = pin; byteWrite[4] = 0x00; byteWrite[5] = (byte)digital; byteWrite[6] = 0xAA; byteWrite[7] = 0xAA; this.Write(byteWrite, 0, byteWrite.Length); }
private void ldd() { ldx(); DE.Dec(); HL.Dec(); }
private void ldi() { ldx(); DE.Inc(); HL.Inc(); }
public override Dictionary <string, string> GetCharacterDisplayCalculationValues() { Dictionary <string, string> dictValues = new Dictionary <string, string>(); dictValues.Add("Status", string.Format("Overall: {0,-10} Fight: {1,-10} Burst: {2,-10}", OverallPoints.ToString("N0"), FightPoints.ToString("N0"), BurstPoints.ToString("N0"))); //Basic Stats dictValues["Health"] = BasicStats.Health.ToString("N00"); dictValues["Stamina"] = BasicStats.Stamina.ToString("N00"); dictValues["Mana"] = BasicStats.Mana.ToString("N00"); dictValues["Intellect"] = BasicStats.Intellect.ToString("N00"); dictValues["Spirit"] = BasicStats.Spirit.ToString("N00"); dictValues["Mastery Rating"] = string.Format("{0}*{1} Mastery Rating", (8 + BasicStats.MasteryRating / 179.28f).ToString("N02"), BasicStats.MasteryRating); dictValues["Spell Power"] = string.Format("{0}", SpellPowerTotal.ToString("N00")); dictValues["Mana Regen"] = string.Format("{0}", ManaRegenRate.ToString("N00")); dictValues["Combat Regen"] = string.Format("{0}", CombatRegenRate.ToString("N00")); // dictValues["Mp5"] = BasicStats.Mp5.ToString("N00"); dictValues["Spell Crit"] = string.Format("{0}%*{1} Crit Rating", (BasicStats.SpellCrit * 100).ToString("N02"), BasicStats.CritRating); dictValues["Spell Haste"] = string.Format("{0}%*Haste breakdown:\nHaste Rating {1} gives {2} haste.\nTalent haste multipliers:\nSpeed of Light: {3}\nJudgements of the Pure: {4}\nOther Haste: {5} (probably from buffs)", (BasicStats.SpellHaste * 100).ToString("N02"), BasicStats.HasteRating, (BasicStats.RangedHaste * 100).ToString("N02"), HasteSoL.ToString("N02"), HasteJotP.ToString("N02"), (((1f + BasicStats.SpellHaste) / (1f + BasicStats.PhysicalHaste) - 1f) * 100f).ToString("N02")); // Cycle Stats dictValues["Total Healed"] = string.Format("{0} healing", TotalHealed.ToString("N00")); dictValues["Total Mana"] = string.Format("{0} mana *Mana Sources:\nBase Mana: {1} \nCombat Regen: {2}\nJudgements: {3}\nReplenishment: {4}\nDivine Plea: {5}\nArcane Torrent: {6}\nLay on Hands: {7}\nMP5: {8}\nMelee: {9}\nOther: {10}", TotalMana.ToString("N00"), ManaBase.ToString("N00"), CombatRegenTotal.ToString("N00"), ManaJudgements.ToString("N00"), ManaReplenishment.ToString("N00"), ManaDivinePlea.ToString("N00"), ManaArcaneTorrent.ToString("N00"), ManaLayOnHands.ToString("N00"), ManaMp5.ToString("N00"), ManaMelee.ToString("N00"), ManaOther.ToString("N00")); dictValues["Average Healing per sec"] = string.Format("{0} hps", AvgHPS.ToString("N00")); dictValues["Average Healing per mana"] = string.Format("{0} hpm", AvgHPM.ToString("N02")); dictValues["Fight Length"] = string.Format("{0} sec *{1} Active Time \n{2} Total Cast Time", FightLength.ToString("N00"), ActiveTime.ToString("N00"), RotationTotal.ToString("N00")); // Healing Breakdown dictValues["Holy Light Healed"] = string.Format("{0} *Holy Light Information: \nNumber of Casts: {1}\nTotal cast time: {2} sec\nTotal mana used: {3}", HealedHL.ToString("N00"), HLCasts.ToString("N01"), RotationHL.ToString("N02"), UsageHL.ToString("N00")); dictValues["Divine Light Healed"] = string.Format("{0} *Divine Light Information: \nNumber of Casts: {1}\nTotal cast time: {2} sec\nTotal mana used: {3}", HealedDL.ToString("N00"), DLCasts.ToString("N01"), RotationDL.ToString("N02"), UsageDL.ToString("N00")); dictValues["Flash of Light Healed"] = string.Format("{0} *Flash of Light Information: \nNumber of Casts: {1}\nTotal cast time: {2} sec\nTotal mana used: {3}", HealedFoL.ToString("N00"), FoLCasts.ToString("N01"), RotationFoL.ToString("N02"), UsageFoL.ToString("N00")); HSCasts = HS.Casts(); // I wasn't sure how to print this directly, so I made this variable to get it to work for now dictValues["Holy Shock Healed"] = string.Format("{0} *Holy Shock Information: \nNumber of Casts: {1}\nTotal cast time: {2} sec\nTotal mana used: {3}", HealedHS.ToString("N00"), HSCasts.ToString("N00"), RotationHS.ToString("N02"), UsageHS.ToString("N00")); dictValues["Word of Glory Healed"] = string.Format("{0} *Word of Glory Information: \nNumber of Casts: {1}\nTotal cast time: {2} sec\nTotal mana used: {3}", HealedWoG.ToString("N00"), WoGCasts.ToString("N00"), RotationWoG.ToString("N02"), UsageWoG.ToString("N00")); dictValues["Light of Dawn Healed"] = string.Format("{0} *Light of Dawn Information: \nNumber of Casts: {1}\nTotal cast time: {2} sec\nTotal mana used: {3}", HealedLoD.ToString("N00"), LoDCasts.ToString("N00"), RotationLoD.ToString("N02"), UsageLoD.ToString("N00")); dictValues["Holy Radiance Healed"] = string.Format("{0} *Holy Radiance Information: \nNumber of Casts: {1}\nTotal cast time: {2} sec\nTotal mana used: {3}", HealedHR.ToString("N00"), HRCasts.ToString("N00"), RotationHR.ToString("N02"), UsageHR.ToString("N00")); BoLCasts = BoL.Casts(); // I wasn't sure how to print this directly, so I made this variable to get it to work for now dictValues["Beacon of Light Healed"] = string.Format("{0} *Beacon of Light Information: \nNumber of Casts: {1}\nTotal cast time: {2} sec\nTotal mana used: {3}", HealedBoL.ToString("N00"), BoLCasts.ToString("N00"), RotationBoL.ToString("N02"), UsageBoL.ToString("N00")); LoHCasts = LoH.Casts(); dictValues["Lay on Hands Healed"] = string.Format("{0} *Lay on Hands Information: \nNumber of Casts: {1}\nTotal cast time: {2} sec\nTotal mana used: {3}", HealedLoH.ToString("N00"), LoHCasts.ToString("N00"), RotationLoH.ToString("N02"), UsageLoH.ToString("N00")); //dictValues["Glyph of HL Healed"] = string.Format("{0} ", HealedGHL.ToString("N00")); take this out, seems like this glyph no longer exists dictValues["Protector of the Innocent "] = string.Format("{0} *Protector of the Innocent Info:\nNumber of Casts: {1}", HealedPotI.ToString("N00"), PotICasts.ToString("N00")); dictValues["Enlightened Judgements "] = string.Format("{0} *Enlightened Judgements Info:\nNumber of Casts: {1}", HealedJudge.ToString("N00"), JudgeCasts.ToString("N00")); dictValues["Illuminated Healing"] = string.Format("{0} *These are from the absorb shields, and increase with Mastery stat.\nThe shields often expire or are overwritten.\nSee options tab to adjust the effective %.", HealedIH.ToString("N00")); dictValues["Cleanse casting"] = string.Format("*Based on the settings from the options tab, you cast Cleanse {0} times, using up {1} mana.", CleanseCasts.ToString("N00"), UsageCleanse.ToString("N00")); dictValues["Other Healed"] = string.Format("{0} ", HealedOther.ToString("N00")); //Spell Details dictValues["Holy Light"] = "*" + HL.ToString(); dictValues["Flash of Light"] = "*" + FoL.ToString(); dictValues["Holy Shock"] = "*" + HS.ToString(); dictValues["Divine Light"] = "*" + DL.ToString(); dictValues["Word of Glory(3 holy power)"] = "*" + WoG.ToString(); dictValues["LoD(3 hp, max targets)"] = "*" + LoD.ToString(); dictValues["Holy Radiance (max)"] = "*" + HR.ToString(); dictValues["Lay on Hands"] = "*" + LoH.ToString(); dictValues["Protector of the Innocent"] = "*" + PotI.ToString(); dictValues["Enlightened Judgements"] = "*" + EJ.ToString(); return(dictValues); }
public override bool IsValid(object value) { HL hlValue = (HL)value; return(hlValue.HL2 == "" && hlValue.HL4 == "1"); }
/* Execute Step Comments: * The temp variables Rs,Rd,Operand8,etc registers are defined in constructor Main() method to avoid memory leaks. * But, this also means they will also retain the same value even after ExecuteStep() is called again. * So, for any temp variables, modify all its constituent variables then only use it. * e.g. Do not use Operand16 by modifying just its LB or HB. */ private void ExecuteStep() { IC++; CCC = CCC + Int32.Parse(I.Names[m[PC.DEC16].DEC8, 2]); if (changeInte == true) //Interrupt control logic (as ei/de affects inte f/f only during next instruction) { if (changeInteTo == true) { inte = true; } else { inte = false; } changeInte = false; UpdateInterrupt(); } Opcode.DEC8 = m[PC.DEC16].DEC8; // * DATA TRANSFER GROUP * if (BitCombination(Opcode[7], Opcode[6]) == "01") //MOV,HLT { //Except Rs=Rd=M 01110110 hlt if (BitCombination(Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "110110") { //Halt Rs=Rd=M 01110110 hlt Stop(); return; } else { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); Set8BitRegisterValue(Rs.DEC8, Opcode[5], Opcode[4], Opcode[3]); PC.INX(); } } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "00110") //MVI Rd,8BitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; Set8BitRegisterValue(Operand8.DEC8, Opcode[5], Opcode[4], Opcode[3]); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "000001") //LXI Rp,16BitData { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; Set16BitRegisterValue(true, Operand16.DEC16, Opcode[5], Opcode[4]); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00111010") //LDA { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = m[Operand16.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00110010") //STA { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; m[Operand16.DEC16].DEC8 = PSW.HB.DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00101010") //LHLD { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; HL.LB.DEC8 = m[Operand16.DEC16].DEC8; Operand16.INX(); HL.HB.DEC8 = m[Operand16.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00100010") //SHLD { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; m[Operand16.DEC16].DEC8 = HL.LB.DEC8; Operand16.INX(); m[Operand16.DEC16].DEC8 = HL.HB.DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00001010") //LDAX B { PSW.HB.DEC8 = m[BC.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00011010") //LDAX D { PSW.HB.DEC8 = m[DE.DEC16].DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11101010") //XCHG { Operand16.DEC16 = HL.DEC16; HL.DEC16 = DE.DEC16; DE.DEC16 = Operand16.DEC16; PC.INX(); } else if (Opcode.DEC8 == 219) //IN 8bitIOPortAddress { PC.INX(); PSW.HB.DEC8 = io[m[PC.DEC16].DEC8].DEC8; PC.INX(); } else if (Opcode.DEC8 == 211) //OUT 8bitIOPortAddress { PC.INX(); io[m[PC.DEC16].DEC8].DEC8 = PSW.HB.DEC8; PC.INX(); } // * ARITHMETIC GROUP * else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10000") //ADD Rs { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10001") //ADC R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); byte i; if (PSW.LB[0] == true) { i = 1; } else { i = 0; } if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble() + i) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8 + i) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 + i - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 + i); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11000110") //ADI 8bitdata { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11001110") //ACI 8bitdata { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; byte i; if (PSW.LB[0] == true) { i = 1; } else { i = 0; } if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble() + i) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8 + i) > 255) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 + i - 256); } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 + i); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "00100") //INR R { Rs.DEC8 = Get8BitRegisterValue(Opcode[5], Opcode[4], Opcode[3]); if (Rs.GetLowerNibble() == 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if (Rs.DEC8 == 255) { Rs.DEC8 = (byte)(0 + 1); } else { Rs.DEC8 = (byte)(Rs.DEC8 + 1); } Set8BitRegisterValue(Rs.DEC8, Opcode[5], Opcode[4], Opcode[3]); UpdateP(Rs.DEC8); UpdateS(Rs.DEC8); UpdateZ(Rs.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10010") //SUB R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); Rs.DEC8 = Rs.Get2sComplement(); //In 2's complement addition, complement both CY and AC. Here, it is done directly in if conditional //by inverting true and false. if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10011") //SBB R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); if (PSW.LB[0] == true) { if (Rs.DEC8 == 255) { Rs.DEC8 = 0; } else { Rs.DEC8 = (byte)(Rs.DEC8 + 1); } } Rs.DEC8 = Rs.Get2sComplement(); if ((PSW.HB.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Rs.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11010110") //SUI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; Operand8.DEC8 = Operand8.Get2sComplement(); if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11011110") //SBI 8BitDAta { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; if (PSW.LB[0] == true) { if (Operand8.DEC8 == 255) { Operand8.DEC8 = 0; } else { Operand8.DEC8 = (byte)(Operand8.DEC8 + 1); } } Operand8.DEC8 = Operand8.Get2sComplement(); if ((PSW.HB.GetLowerNibble() + Operand8.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((PSW.HB.DEC8 + Operand8.DEC8) > 255) { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8 - 256); } else { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + Operand8.DEC8); } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "00101") //DCR R { /*Rs.DEC8 = Get8BitRegisterValue(Opcode[5], Opcode[4], Opcode[3]); * * Rs.DEC8 = Rs.Get2sComplement(); * * if (Rs.GetLowerNibble() == 15) * PSW.LB[4] = true; * else * PSW.LB[4] = false; * * if (Rs.DEC8 == 255) * { * Rs.DEC8 = (byte)(0 + 1); * } * else * { * Rs.DEC8 = (byte)(Rs.DEC8 + 1); * } * * Set8BitRegisterValue(Rs.DEC8, Opcode[5], Opcode[4], Opcode[3]); * UpdateP(Rs.DEC8); * UpdateS(Rs.DEC8); * UpdateZ(Rs.DEC8); * * PC.INX(); * */ Rd.DEC8 = Get8BitRegisterValue(Opcode[5], Opcode[4], Opcode[3]); Rs.DEC8 = 1; //As 1 is substracted Rs.DEC8 = Rs.Get2sComplement(); //In 2's complement addition, complement both CY and AC. Here, it is done directly in if conditional //by inverting true and false. if ((Rd.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((Rd.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; Rd.DEC8 = (byte)(Rd.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; Rd.DEC8 = (byte)(Rd.DEC8 + Rs.DEC8); } Set8BitRegisterValue(Rd.DEC8, Opcode[5], Opcode[4], Opcode[3]); UpdateP(Rd.DEC8); UpdateS(Rd.DEC8); UpdateZ(Rd.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "000011") //INX Rp { switch (BitCombination(Opcode[5], Opcode[4])) { case "00": { BC.INX(); break; } case "01": { DE.INX(); break; } case "10": { HL.INX(); break; } case "11": { SP.INX(); break; } } PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "001011") //DCX Rp { switch (BitCombination(Opcode[5], Opcode[4])) { case "00": { BC.DCX(); break; } case "01": { DE.DCX(); break; } case "10": { HL.DCX(); break; } case "11": { SP.DCX(); break; } } PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "001001") //DAD Rp,16BitData { Operand16.DEC16 = Get16BitRegisterValue(true, Opcode[5], Opcode[4]); if ((HL.DEC16 + Operand16.DEC16) > 65535) { PSW.LB[0] = true; HL.DEC16 = (ushort)(HL.DEC16 + Operand16.DEC16 - 65536); } else { PSW.LB[0] = false; HL.DEC16 = (ushort)(HL.DEC16 + Operand16.DEC16); } PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00100111") //DAA { if ((PSW.HB.GetLowerNibble() > 9) || (PSW.LB[4] == true)) { //Add 6 to lower nibble if ((PSW.HB.GetLowerNibble() + 6) > 15) { PSW.LB[4] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + 6 - 16); //6 is added, 16 is sub to neutralize overflow out of nibble } else { PSW.LB[4] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + 6); } } else { PSW.LB[4] = false; } byte i; if (PSW.LB[4] == true) { i = 1; } else { i = 0; } if ((PSW.HB.GetHigherNibble() > 9) || (PSW.LB[0] == true)) { bool PreviousCY = PSW.LB[0]; //Add 6 to higher nibble if ((PSW.HB.GetHigherNibble() + 6 + i) > 15) { PSW.LB[0] = true; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + (6 + i - 16) * 16); //i is carry from lower nibble, Multiply by 16 to reach uppaer nibble ( i.e. up by 4 bits 2^4) } else { PSW.LB[0] = false; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 + (6 + i) * 16); } if (PreviousCY) //Set CY if it was initially set { PSW.LB[0] = true; } } UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } // * LOGICAL GROUP * else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10100") //ANA R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 & Rs.DEC8); PSW.LB[0] = false; PSW.LB[4] = true; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11100110") //ANI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 & Operand8.DEC8); PSW.LB[0] = false; PSW.LB[4] = true; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10110") //ORA R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 | Rs.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11110110") //ORI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 | Operand8.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10101") //XRA R { Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 ^ Rs.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11101110") //XRI 8bitData { PC.INX(); Operand8.DEC8 = m[PC.DEC16].DEC8; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 ^ Operand8.DEC8); PSW.LB[0] = false; PSW.LB[4] = false; UpdateP(PSW.HB.DEC8); UpdateS(PSW.HB.DEC8); UpdateZ(PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00101111") //CMA { PSW.HB.DEC8 = (byte)(~PSW.HB.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00111111") //CMC { PSW.LB[0] = !PSW.LB[0]; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00110111") //STC { PSW.LB[0] = true; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10111") //CMP R { Operand8.DEC8 = PSW.HB.DEC8; Rs.DEC8 = Get8BitRegisterValue(Opcode[2], Opcode[1], Opcode[0]); Rs.DEC8 = Rs.Get2sComplement(); if ((Operand8.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((Operand8.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8); } UpdateP(Operand8.DEC8); UpdateS(Operand8.DEC8); UpdateZ(Operand8.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3]) == "10111") //CPI 8bitData { Operand8.DEC8 = PSW.HB.DEC8; PC.INX(); Rs.DEC8 = m[PC.DEC16].DEC8; Rs.DEC8 = Rs.Get2sComplement(); if ((Operand8.GetLowerNibble() + Rs.GetLowerNibble()) > 15) { PSW.LB[4] = true; } else { PSW.LB[4] = false; } if ((Operand8.DEC8 + Rs.DEC8) > 255) { PSW.LB[0] = false; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8 - 256); } else { PSW.LB[0] = true; Operand8.DEC8 = (byte)(Operand8.DEC8 + Rs.DEC8); } UpdateP(Operand8.DEC8); UpdateS(Operand8.DEC8); UpdateZ(Operand8.DEC8); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00000111") //RLC { bool D7 = PSW.HB[7]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 << 1); PSW.HB[0] = D7; PSW.LB[0] = D7; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00001111") //RRC { bool D0 = PSW.HB[0]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 >> 1); PSW.HB[7] = D0; PSW.LB[0] = D0; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00010111") //RAL { bool D7 = PSW.HB[7]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 << 1); PSW.HB[0] = PSW.LB[0]; PSW.LB[0] = D7; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "00011111") //RAR { bool D0 = PSW.HB[0]; PSW.HB.DEC8 = (byte)(PSW.HB.DEC8 >> 1); PSW.HB[7] = PSW.LB[0]; PSW.LB[0] = D0; PC.INX(); } // * STACK AND MACHINE CONTROL GROUP * else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "110101") //PUSH Rp { //FOR Push/Pop and in Branching only , IsSP = false i.e. return PC Operand16.DEC16 = Get16BitRegisterValue(false, Opcode[5], Opcode[4]); SP.DCX(); m[SP.DEC16].DEC8 = Operand16.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = Operand16.LB.DEC8; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "110001") //POP Rp { Operand16.LB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Operand16.HB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Set16BitRegisterValue(false, Operand16.DEC16, Opcode[5], Opcode[4]); PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11111001") //SPHL { SP.DEC16 = HL.DEC16; PC.INX(); } else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11100011") //XTHL { Operand16.DEC16 = HL.DEC16; HL.LB.DEC8 = m[SP.DEC16].DEC8; m[SP.DEC16].DEC8 = Operand16.LB.DEC8; if (SP.DEC16 == 255) //Check for overflow { HL.HB.DEC8 = m[0].DEC8; m[0].DEC8 = Operand16.HB.DEC8; } else { HL.HB.DEC8 = m[SP.DEC16 + 1].DEC8; m[SP.DEC16 + 1].DEC8 = Operand16.HB.DEC8; } PC.INX(); } else if (Opcode.DEC8 == 0) //NOP { PC.INX(); } else if (Opcode.DEC8 == 251) //EI { changeInte = true; changeInteTo = true; PC.INX(); } else if (Opcode.DEC8 == 251) //DI { changeInte = true; changeInteTo = false; PC.INX(); } else if (Opcode.DEC8 == 32) //RIM { //Read sid and output to d7 bit of accumulator if (rbSid0.IsChecked == true) { PC.HB[7] = false; } else { PC.HB[7] = true; } //No logic for interrupts pending in simulator //Read inte if (inte == true) { PC.HB[3] = true; } else { PC.HB[3] = false; } //Reads masks if (interrupt[2] == true) //M7.5 { PC.HB[2] = true; } else { PC.HB[2] = false; } if (interrupt[1] == true) //M6.5 { PC.HB[1] = true; } else { PC.HB[1] = false; } if (interrupt[0] == true) //M5.5 { PC.HB[0] = true; } else { PC.HB[0] = false; } PC.INX(); UpdateInterrupt(); } else if (Opcode.DEC8 == 48) //SIM { //Set sod=1 if sde=1 else sod=0 if (PC.HB[6] == true) { if (PC.HB[7] == true) { tbSod.Text = "1"; } else { tbSod.Text = "0"; } } if (PC.HB[4] == true) //Resets r7.5 f/f, else has no effect { r75 = false; } if (PC.HB[3] == true) //MSE { if (PC.HB[2] == true) //M'7.5 { interrupt[2] = true; } else { interrupt[2] = false; } if (PC.HB[1] == true) //M'6.5 { interrupt[1] = true; } else { interrupt[1] = false; } if (PC.HB[0] == true) //M'5.5 { interrupt[0] = true; } else { interrupt[0] = false; } } PC.INX(); UpdateInterrupt(); } // * BRANCH GROUP * //In branch group, take care of whether to execute PC.INX() or not at end. else if (BitCombination(Opcode[7], Opcode[6], Opcode[5], Opcode[4], Opcode[3], Opcode[2], Opcode[1], Opcode[0]) == "11101001") //PCHL { PC.DEC16 = HL.DEC16; } else if (Opcode.DEC8 == 195) //JMP { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.DEC16 = Operand16.DEC16; } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11010") //Conditional Jump { if (CheckCondition(Opcode[5], Opcode[4], Opcode[3]) == true) { PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.DEC16 = Operand16.DEC16; } else { PC.INX(); PC.INX(); PC.INX(); } } else if (Opcode.DEC8 == 205) //CALL { //Storing address to be branched in temp register Operand16 PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); //Push contents of PC onto stack SP.DCX(); m[SP.DEC16].DEC8 = PC.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = PC.LB.DEC8; //Branch PC.DEC16 = Operand16.DEC16; } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11100") //Conditional CALL { if (CheckCondition(Opcode[5], Opcode[4], Opcode[3]) == true) { //Storing address to be branched in temp register Operand16 PC.INX(); Operand16.LB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); Operand16.HB.DEC8 = m[PC.DEC16].DEC8; PC.INX(); //Push contents of PC onto stack SP.DCX(); m[SP.DEC16].DEC8 = PC.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = PC.LB.DEC8; //Branch PC.DEC16 = Operand16.DEC16; } else { PC.INX(); PC.INX(); PC.INX(); } } else if (Opcode.DEC8 == 201) //RET { //Pop content from stack to temp RegisterPair Operand16 Operand16.LB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Operand16.HB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); //Branch PC.DEC16 = Operand16.DEC16; } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11000") //Conditional Return { if (CheckCondition(Opcode[5], Opcode[4], Opcode[3]) == true) { Operand16.LB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); Operand16.HB.DEC8 = m[SP.DEC16].DEC8; SP.INX(); //Branch PC.DEC16 = Operand16.DEC16; } else { PC.INX(); } } else if (BitCombination(Opcode[7], Opcode[6], Opcode[2], Opcode[1], Opcode[0]) == "11111") //RST N { PC.INX(); //Push contents of PC onto stack SP.DCX(); m[SP.DEC16].DEC8 = PC.HB.DEC8; SP.DCX(); m[SP.DEC16].DEC8 = PC.LB.DEC8; //Branch switch (BitCombination(Opcode[5], Opcode[4], Opcode[3])) { case "000": { PC.DEC16 = 0; break; } case "001": { PC.DEC16 = 8; break; } case "010": { PC.DEC16 = 16; break; } case "011": { PC.DEC16 = 24; break; } case "100": { PC.DEC16 = 32; break; } case "101": { PC.DEC16 = 40; break; } case "110": { PC.DEC16 = 48; break; } case "111": { PC.DEC16 = 56; break; } } } else { //Unrecognised Instructions PC.INX(); } RefreshMIO(false); //Nofocus, as it will cause Stop button never to gain focus UpdateAll(); //Rucurse in Fast Mode but in idle priority if (rbFast.IsChecked == true) { bStep.IsEnabled = false; if (IsStopped == false) { bStart.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new ExecuteStepDelegate(ExecuteStep)); } } }
public static void PrintHorizontalLine(int indent) { Console.WriteLine(new string(' ', indent) + HL.Substring(indent)); }
public Graph() { var n0 = new Node(300, 300); var n1 = new Node("FFFF"); var n2 = new Node("7834"); var n3 = new Node("2834"); //var n0 = new Node(124); //Console.WriteLine("An element ID: {0}", n0.ID); //var n1 = new Node(254); //Console.WriteLine("An element ID: {0}", n1.ID); //var n2 = new Node(172); //Console.WriteLine("An element ID: {0}", n2.ID); //var n3 = new Node(94); //Console.WriteLine("An element ID: {0}", n3.ID); //var n4 = new Node(47); //Console.WriteLine("An element ID: {0}", n4.ID); ////var n5 = new Node(49); ////Console.WriteLine("An element ID: {0}", n5.ID); //var n5 = new Node(2); //Console.WriteLine("An element ID: {0}", n5.ID); VertexList.Add(n0); VertexList.Add(n1); VertexList.Add(n2); VertexList.Add(n3); //VertexList.Add(n4); //VertexList.Add(n5); //Console.WriteLine(); for (int i = 1; i < 51; i++) { var nn = new Node(i * 6 - 4); Console.WriteLine("An element ID: {0}", nn.ID); VertexList.Add(nn); } //Console.WriteLine(); //Generate(VertexList.Count, 2); //AddEdge(0, 3); //AddEdge(1, 3); //AddEdge(2, 3); //AddEdge(3, 4); //AddEdge(4, 2); //AddEdge(0, 1); //AddEdge(0, 5); for (int i = 0; i < EdgeList.Count; i++) { AdjacencyList.Add(EdgeList[i].v1); HL.Add(-1); } for (int i = EdgeList.Count - 1; i >= 0; i--) { AdjacencyList.Add(EdgeList[i].v2); } for (int k = 0; k < AdjacencyList.Count; k++) { int i = AdjacencyList[k]; LL.Add(HL[i]); HL[i] = k; } this.GraphWrite(); //Console.WriteLine("Обход списка рёбер вершины 2"); //int v = 2; //for(int k = HL[v]; k!=-1; k = LL[k]) //{ // int j = AdjacencyList[AdjacencyList.Count - 1-k]; // Console.WriteLine("{0} - {1}", v, j); //} //foreach (Node v in VertexList) //{ // Console.WriteLine("\n\n\nNode IP: {0}, Node ID: {1}", v.ip, v.ID); // v.WriteNeighboorhoodSet(); // int pref = v.ComparePrefixes(v.ID, VertexList[0].ID); // // Console.WriteLine("\nPrefixes ID1: {0}, ID2: {1}, {2}", v.ID, VertexList[0].ID, pref); // v.WriteLeafSet(); // v.WriteRoutingTable(); //} }