static public void SecondTasks() { double a = InputValue("A"), b = InputValue("B"), h = InputValue("H"); if (a > b) { Console.WriteLine("Error a > b"); return; } if (a + h < a) { Console.WriteLine("Error a + n < a"); return; } double e = InputValue("e"); string ans = ""; for (double i = a; i <= b; i += h) { ans += SCPU.Task2(i, e); ans += "\n"; } Console.WriteLine(ans); }
public static void Clear() { foreach (DictionaryEntry reg in registors) { (reg.Value as Register).Clear(); } ClearFlags(); SCPU.Clear(); }
static public void KoshiTask(string method) { Dictionary <string, double> data = InputDataForKoshi(); //Dictionary<string, double> data = TestData(); if (data == null) { return; } List <double> yValues = new List <double> { data["y0"] }; Console.WriteLine("y(0) = {0}, x(0) = {1}", data["y0"], data["a"]); double yCurr = data["y0"]; if (method == "Adams") { double fxy = SCPU.FindFXY(data, data["a"], data["y0"]); yValues.Add(yValues[0] + data["h"] / 2 * 3 * fxy); } for (double xCurr = data["a"]; xCurr <= data["b"]; xCurr += data["h"]) { if (method == "Eiler") { double fxy = SCPU.FindFXY(data, xCurr, yCurr); yCurr = SCPU.Eiler(yCurr, data["h"], fxy, data["visual"]); yValues.Add(yCurr); } else if (method == "Adams" && xCurr != data["a"]) { double fxy0 = SCPU.FindFXY(data, xCurr - data["h"], yValues[yValues.Count() - 2]); double fxy1 = SCPU.FindFXY(data, xCurr, yValues[yValues.Count() - 1]); yCurr = SCPU.Adams(fxy0, fxy1, yValues[yValues.Count() - 1], data["h"], data["visual"]); //Console.WriteLine("\n Answer" + ' ' + fxy0+ ' ' + fxy1 + ' ' + yCurr); yValues.Add(yCurr); } } int i = 0; Console.WriteLine("\nTable calculations of method " + method + ":"); for (double x = data["a"]; x <= data["b"]; x += data["h"], i++) { Console.WriteLine("y({0}) = {1})", x, yValues[i]); } }
static public void FirstTasks() { double a, b, c; while (true) { Console.Write("Please input a = "); string s = Console.ReadLine(); if (double.TryParse(s, out a)) { break; } else { Console.WriteLine("Repeat the command!"); } } while (true) { Console.Write("Please input b = "); string s = Console.ReadLine(); if (double.TryParse(s, out b)) { break; } else { Console.WriteLine("Repeat the command!"); } } while (true) { Console.Write("Please input c = "); string s = Console.ReadLine(); if (double.TryParse(s, out c)) { break; } else { Console.WriteLine("Repeat the command!"); } } SCPU.Task1(a, b, c); }
public static void Status() { foreach (DictionaryEntry reg in registors) { (reg.Value as Register).Info(); } Console.WriteLine(); foreach (var fg in flags) { Console.Write("{0}={1} ", fg.Key, Convert.ToSByte(fg.Value)); } Console.Write("\n\n"); SCPU.Info(); Console.Write("\n\n"); }
static public void SecondTasks() { double a, b, h, e; while (true) { Console.Write("Please input A = "); string s = Console.ReadLine(); if (double.TryParse(s, out a)) { break; } else { Console.WriteLine("Repeat the command!"); } } while (true) { Console.Write("Please input B = "); string s = Console.ReadLine(); if (double.TryParse(s, out b)) { break; } else { Console.WriteLine("Repeat the command!"); } } while (true) { Console.Write("Please input H = "); string s = Console.ReadLine(); if (double.TryParse(s, out h)) { break; } else { Console.WriteLine("Repeat the command!"); } } if (a > b) { Console.WriteLine("Error a > b"); return; } if (a + h < a) { Console.WriteLine("Error a + n < a"); return; } while (true) { Console.Write("Please input e = "); string s = Console.ReadLine(); if (double.TryParse(s, out e)) { break; } else { Console.WriteLine("Repeat the command!"); } } string ans = ""; for (double i = a; i <= b; i += h) { ans += SCPU.Task2(i, e); ans += "\n"; } Console.WriteLine(ans); }
static public void FirstTasks() { double a = InputValue("a"), b = InputValue("b"), c = InputValue("c"); SCPU.Task1(a, b, c); }
private static void MyCommand(string command) { string[] words = Checker.FormattingMyCommand(command); switch (words[0]) { case "mov": if (!Checker.CheckCommandMOVandADD(words)) { Console.WriteLine("Error entering command MOV"); } else { ALU.MOV(words[1], words[2]); } break; case "add": CPU.ClearFlags(); if (!Checker.CheckCommandMOVandADD(words)) { Console.WriteLine("Error entering command ADD"); } else { ALU.ADD(words[1], words[2]); } break; case "sub": CPU.ClearFlags(); if (!Checker.CheckCommandMOVandADD(words)) { Console.WriteLine("Error entering command SUB"); } else { ALU.SUB(words[1], words[2]); } break; case "mul": CPU.ClearFlags(); if (!Checker.CheckCommandMULandDIV(words)) { Console.WriteLine("Error entering command MUL"); } else { ALU.MUL(words[1]); } break; case "div": CPU.ClearFlags(); if (!Checker.CheckCommandMULandDIV(words)) { Console.WriteLine("Error entering command DIV"); } else { ALU.DIV(words[1]); } break; case "fmov": if (!Checker.CheckCommandFMOV(words)) { Console.WriteLine("Error entering command FMOV"); } else { SCPU.FMOV(words[1], words[2]); } break; case "fadd": if (!Checker.CheckCommandFloat(words)) { Console.WriteLine("Error entering command FADD"); } else { SCPU.FADD(words[1], words[2]); } break; case "fsub": if (!Checker.CheckCommandFloat(words)) { Console.WriteLine("Error entering command FSUB"); } else { SCPU.FSUB(words[1], words[2]); } break; case "fmul": if (!Checker.CheckCommandFloat(words)) { Console.WriteLine("Error entering command FMUL"); } else { SCPU.FMUL(words[1], words[2]); } break; case "fdiv": if (!Checker.CheckCommandFloat(words)) { Console.WriteLine("Error entering command FDIV"); } else { SCPU.FDIV(words[1], words[2]); } break; case "tasks": if (words.Length == 1) { MyTasks(); } else { Console.WriteLine("Error entering command TASKS"); } break; default: Console.WriteLine("Error command!"); break; } }