public string getfunct(string instruction) { global temp = new global(); if (instruction == "add") { return(temp.getBinary(32)); } if (instruction == "and") { return(temp.getBinary(36)); } if (instruction == "sub") { return(temp.getBinary(34)); } if (instruction == "nor") { return(temp.getBinary(39)); } if (instruction == "or") { return(temp.getBinary(37)); } return(temp.getBinary(42)); }
public R(List <string> arguments) { string instruction = arguments[0]; string reg1 = arguments[1]; string reg2 = arguments[2]; string reg3 = arguments[3]; if (reg1.Last() == ',') { reg1 = reg1.Substring(0, reg1.Length - 1); } if (reg2.Last() == ',') { reg2 = reg2.Substring(0, reg2.Length - 1); } if (reg3.Last() == ',') { reg3 = reg3.Substring(0, reg3.Length - 1); } global temp = new global(); string r1 = temp.numofreg(reg2), r2 = temp.numofreg(reg3), r3 = temp.numofreg(reg1); string fun = getfunct(instruction); mask += "000000"; mask += r1; mask += r2; mask += r3; mask += "00000"; mask += fun; }
public string getfunct(string instruction) { global temp = new global(); if (instruction == "add") { return(global.getBinary(32, 6)); } if (instruction == "and") { return(global.getBinary(36, 6)); } if (instruction == "sub") { return(global.getBinary(34, 6)); } if (instruction == "nor") { return(global.getBinary(39, 6)); } if (instruction == "or") { return(global.getBinary(37, 6)); } return(global.getBinary(42, 6)); }
public I(List <string> arguments) { global temp = new global(); if (arguments[0] == "lw" || arguments[0] == "sw") { mask += getfunct(arguments[0]); string s = arguments[2], t = ""; int st = 0; for (int i = 0; i < arguments[2].Length; i++) { if (arguments[2][i] == '(') { st = i + 1; break; } } for (; arguments[2][st] != ')'; st++) { t += arguments[2][st]; } mask += temp.numofreg(t); mask += temp.numofreg(arguments[1]); t = ""; for (int i = 0; i < arguments[2].Length && arguments[2][i] != '('; i++) { t += arguments[2][i]; } if (t.Length > 1 && t[1] == 'x') { t = t.Substring(2, t.Length - 2); } int num = Int32.Parse(t, System.Globalization.NumberStyles.HexNumber); mask += global.getBinary(num, 16); } else { mask += getfunct(arguments[0]); mask += temp.numofreg(arguments[2]); mask += temp.numofreg(arguments[1]); if (arguments[0] == "addi") { mask += global.getBinary(int.Parse(arguments[3]), 16); } else { mask += global.label_address[arguments[3]]; } } }
public string getfunct(string instruction) { global temp = new global(); if (instruction == "addi") { return(global.getBinary(8, 6)); } if (instruction == "lw") { return(global.getBinary(35, 6)); } if (instruction == "sw") { return(global.getBinary(43, 6)); } if (instruction == "beq") { return(global.getBinary(4, 6)); } return(global.getBinary(5, 6)); }