Relative Content

Tag Archive for pythonassemblymips

i need to create a simple assembler program for the MIPS assembly language by using Python. and output file should contain adresses and machine codes

def read_input_file(filename): with open(filename, ‘r’) as file: lines = file.readlines() return lines def parse_line(line): # Split the line by whitespace parts = line.split() # Check if the line is a label if len(parts) == 1 and parts[0].endswith(‘:’): label = parts[0][:-1] # Remove the colon return “LABEL”, label # Extract instruction and operands instruction = parts[0] […]