diff options
| author | rozlette <uberpanzermensch@gmail.com> | 2019-09-20 20:47:01 -0500 |
|---|---|---|
| committer | rozlette <uberpanzermensch@gmail.com> | 2019-09-20 20:47:01 -0500 |
| commit | 2581bed7bf640becf3522b43f2cfd8e96cfcb997 (patch) | |
| tree | 21fe5caa71003ddcb6223c67d5cc9e51e915443b /tools | |
| parent | 4c11f2f36475bca9b8a2ea52a63e57da3cbbc9cd (diff) | |
Use per-function ASM blocks
Diffstat (limited to 'tools')
| m--------- | tools/asm-processor | 0 | ||||
| -rw-r--r-- | tools/split_asm.py | 45 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tools/asm-processor b/tools/asm-processor -Subproject 7ca3a6009185b629b6b4d0a3d18a1f1d83f3b5a +Subproject 35234f294afe646bb07e6ff489ebcfd47e808f6 diff --git a/tools/split_asm.py b/tools/split_asm.py new file mode 100644 index 000000000..000921e12 --- /dev/null +++ b/tools/split_asm.py @@ -0,0 +1,45 @@ +import argparse, os + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('input', help='input file') + parser.add_argument('output', help='output file path') + parser.add_argument('-c', '--c-base', help='create base c file that has GLOBAL_ASM for each function', metavar='file') + args = parser.parse_args() + + os.makedirs(args.output, exist_ok=True) + + file_names = [] + + with open(args.input, 'r') as f: + current_file = None + writing = False + lines = f.readlines() + for line in lines: + if line.startswith('glabel'): + if current_file != None: + current_file.close() + func_name = line.split()[1] + + assert(func_name != '') + + file_name = args.output + '/' + func_name + '.asm' + current_file = open(file_name, 'w') + writing = True + file_names.append(file_name) + + if '.word' in line: + writing = False + + if writing: + current_file.write(line) + + if current_file != None: + current_file.close() + + if args.c_base != None: + with open(args.c_base, 'w') as f: + for name in file_names: + f.write('GLOBAL_ASM("{}")\n\n'.format(name)) + |
