from instruction_table import untabulate_instructions_sh4 from instruction_file_name import instruction_file_name for ins in untabulate_instructions_sh4(): code = list(f'{ins.code.code_bits:016b}') for operand in ins.code.operands.values(): for i in range(operand.lsb, operand.lsb + operand.length): code[15 - i] = operand.operand file_name = instruction_file_name(ins) path = os.path.join("sh4", file_name) assert not os.path.exists(path) with open(path, 'w') as f: f.write(''.join(code) + '\n')