def fetch(self): instrToFetch = self.state.instrBufferSize - len(self.state.instrBuffer) '''print "InstrBuffer has " + str(len(self.state.instrBuffer)) + " entries" print "There are " + str(self.state.instrBufferSize) + " total spaces" print "Need to fetch " + str(instrToFetch)''' for i in range(instrToFetch): instruction = Instruction(self.state.instructions[self.state.programCounter + i]) instruction.parse() #print "Grabbed instruction " + str(instruction) self.state.instrBuffer.append(instruction) self.state.programCounter += instrToFetch return
def populate_table(table: SymbolTable, instructions: Iterator[str]) -> Iterator[Instruction]: """ first pass: populate symbol table with labels """ instruction_number = 0 for line in instructions: parsed = Instruction.parse(line) if isinstance(parsed, Label): table.put_label(parsed, instruction_number) else: instruction_number += 1 yield parsed