def disasm_add(instruction, pos, line): ins = 'add ' + reverse_register.get(int(instruction[16:21], 2), 'error') + ', ' + \ reverse_register.get(int(instruction[6:11], 2), 'error') + ', ' + \ reverse_register.get(int(instruction[11:16], 2), 'error') if re.search('error', ins): raise Exception('Line %d : No such register.' % line) return ins, -1
def disasm_blez(instruction, pos, line): if pos.get(line + int(int_comp(instruction[16:32]), 10), '') == '': ins = 'blez ' + reverse_register.get(int(instruction[6:11], 2), 'error') \ + ', ' + 'label_%d' % len(pos) else: ins = 'blez ' + reverse_register.get(int(instruction[6:11], 2), 'error') \ + ', ' + 'label_%d' % pos[line + int(int_comp(instruction[16:32]), 10)] if re.search('error', ins): raise Exception('Line %d : No such register.' % line) return ins, line + int(int_comp(instruction[16:32]), 10)
def disasm_mthi(instruction, pos, line): ins = 'mthi ' + reverse_register.get(int(instruction[6:11], 2), 'error') if re.search('error', ins): raise Exception('Line %d : No such register.' % line) return ins, -1
def disasm_sll(instruction, pos, line): ins = 'sll ' + reverse_register.get(int(instruction[16:21], 2), 'error') + ', ' \ + reverse_register.get(int(instruction[11:16], 2), 'error') + ', ' + str(int(instruction[21:26],2)) if re.search('error', ins): raise Exception('Line %d : No such register.' % line) return ins, -1
def disasm_lb(instruction, pos, line): ins = 'lb ' + reverse_register.get(int(instruction[11:16], 2), 'error') + ', '\ + int_comp(instruction[16:32])+'('+ reverse_register.get(int(instruction[6:11], 2), 'error') + ')' if re.search('error', ins): raise Exception('Line %d : No such register.' % line) return ins, -1
def disasm_lui(instruction, pos, line): ins = 'lui ' + reverse_register.get(int(instruction[11:16], 2), 'error') \ + ', ' + int_comp(instruction[16:32]) if re.search('error', ins): raise Exception('Line %d : No such register.' % line) return ins, -1