private Error processTextSection() { new Error(); int startAddress = Instruction.startAddressOfInst; int currentAddr = startAddress; Error err; for (int i = 0; i < this.sourceOfTextSection.size(); ++i) { String str = (String) this.sourceOfTextSection.get(i); str = MyLibrary.removeBeginningAndEndingSpace(str); if (!str.equals("")) { if (this.doesStartWithLevel(str)) { String instr = this.getLevelName(str); Instruction.addressOfLevels.put(instr, Integer.valueOf(currentAddr)); str = str.substring(instr.length() + 1); str = MyLibrary.removeBeginningAndEndingSpace(str); } if (!str.equals("")) { Instruction var7 = new Instruction(); this.CodeSection.add(str); err = var7.parsInstruction(str, "\n\t" + str); if (!err.isOk()) { return err; } this.AllInstructions.add(var7); currentAddr += 4; } } } err = this.FillAllLevelNamesWithTheirAddress(); return err; }
public Error runCurrentInstruction() { Error err = new Error(); Register var10000 = this.Reg; int currentPC = Register.getPC(); int startPC = Instruction.startAddressOfInst; int index = (currentPC - startPC) / 4; if (index < this.AllInstructions.size()) { Instruction instr = (Instruction) this.AllInstructions.get(index); err = instr.runSingleInstruction(); } return err; }
private Error FillAllLevelNamesWithTheirAddress() { Error err = new Error(); for (int i = 0; i < this.AllInstructions.size(); ++i) { Instruction inst = (Instruction) this.AllInstructions.get(i); err = inst.fillLevelNameWithAddress(); if (!err.isOk()) { return err; } this.AllInstructions.set(i, inst); } return err; }
private void RunAllInstructions() throws IOException { int PClimit = Register.getPC() + this.AllInstructions.size() * 4; int startPC = Instruction.startAddressOfInst; while (true) { Register var10000 = this.Reg; int currentPC = Register.getPC(); if (currentPC >= PClimit) { break; } int index = (currentPC - startPC) / 4; Instruction instr = (Instruction) this.AllInstructions.get(index); Error err = instr.runSingleInstruction(); if (!err.isOk()) { err.printErrorMsg(); break; } } }
private void printAllInstructions() { for (int i = 0; i < this.AllInstructions.size(); ++i) { System.out.println("\nPrinting " + i + "th instruction"); System.out.println("mnemonic " + ((Instruction) this.AllInstructions.get(i)).getMnemonic()); Instruction instr = (Instruction) this.AllInstructions.get(i); int NumOp = instr.getNumberOfOperands(); int[] operands = instr.getOperands(); boolean[] isImmediate = instr.getIsImmediate(); int[] sign = instr.getSign(); for (int j = 0; j < NumOp; ++j) { System.out.printf( "%d %s %d\n", new Object[] { Integer.valueOf(operands[j]), isImmediate[j] ? "Immediate" : "Register", Integer.valueOf(sign[j]) }); } } }