Example #1
0
 def get_Instrs(self, asm_file):
     """--------------------------------------------------------------
     Reads the file with the assembler code and puts the instructions
     in the list to be returned
     -----------------------------------------------------------------"""
     #Object to read the asm code
     reader = Reader(asm_file)
     #List to store the instructions
     instrs = []
     for instr in reader.get_Text_Lines():
         instr = instr.replace(" ", "")
         if instr != "" and not instr.startswith("."):
             #Replaces some characteres by spaces
             instr = instr.rstrip('\n').replace(",", " ")
             instr = instr.replace("(", " ")
             instr = instr.replace(")", " ")
             instr = instr.replace("\t", " ")
             #Adds the line to the list
             instrs.append(instr)
     return instrs
Example #2
0
 def get_Instrs_by_Operations_Dic(self):
     """------------------------------------------------------------------
     Returns a dictionary that contains, for every ALU operation, the
     intructions that require the operation. For doing this, reads the file
     instrs_operations_data.
     ------------------------------------------------------------------"""
     #Object to read the asm_data
     reader = Reader(INSTRS_BY_OPERATION_FILE)
     #Dictionary to be returned
     dic = {}
     #Text lines are got in a list
     for line in reader.get_Text_Lines():
         if line.startswith("*"):
             line = line.rstrip('\n').replace(",", "")
             #The instruction is splitted
             parts = line.split(" ")
             #Removes the * character of the list
             parts = parts[1:]
             dic[parts[0]] = parts[2:]
     return dic