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; }
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; }
public MIPSProgram(String source) throws IOException { this.readSource(source); this.removeComment(); this.splitDataAndTextSection(); Error err = this.processDataSection(); if (!err.isOk()) { err.printErrorMsg(); this.assembleTimeError = err; } else { err = this.processTextSection(); if (!err.isOk()) { err.printErrorMsg(); this.assembleTimeError = 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 Error processDataSection() { Error err = new Error(); for (int i = 0; i < this.sourceOfDataSection.size(); ++i) { String str = (String) this.sourceOfDataSection.get(i); if (this.doesStartWithLevel(str)) { String levelName = this.getLevelName(str); Memory var10000 = this.Mem; Memory.setBeginingAddressOfWord(levelName); err = this.processDirectives(str.substring(levelName.length() + 1), "\n\t" + str); } else { err = this.processDirectives(str, "\n\t" + str); } if (!err.isOk()) { break; } } return err; }