static void Main(string[] args) { //this part is for checking read_from_file funtion String[] machineCodes = new string[20]; int lineCount = 0; read_from_file(machineCodes, ref lineCount); //initializing the register file Array.Clear(RegisterFile.Registers, 0, 16); //initializing the memory Array.Clear(Memory.datas, 0, 8193); //checking RTdecoder class if it works correctly if (File.Exists("file.txt")) { string mc = machineCodes[0]; RTdecoder rtd = new RTdecoder(); rtd.calc(mc); } else { Console.WriteLine("file.txt" + " Does not exist! So we can not decode any thing!"); } }
// function for finding the type of instruction static string check_type(string op) { RTdecoder rtd = new RTdecoder(); ITdecoder itd = new ITdecoder(); JTdecoder jtd = new JTdecoder(); // checking if the instruction is R type foreach (KeyValuePair <string, string> item in rtd.instructions) { if (op == item.Key) { return("r"); } } // checking if the instruction is I type foreach (KeyValuePair <string, string> item in itd.instructions) { if (op == item.Key) { return("i"); } } // checking if the instruction is J type foreach (KeyValuePair <string, string> item in jtd.instructions) { if (op == item.Key) { return("j"); } } // what about directives? how to find out them? return(""); }