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 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]]; } } }