diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2021-03-04 17:29:56 +0100 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2021-03-06 14:53:33 +0100 |
| commit | 174694a99b646040b93dec1a6d432f453ae9b7e5 (patch) | |
| tree | 0f6228bd3e33a7100949cb6feb8c26ba0824e4a3 /tools/script_disassembler/script_disassembler.py | |
| parent | 3336b91812c09255e307a9f66dd1ae30aabe027f (diff) | |
Generate using inline assembly
Diffstat (limited to 'tools/script_disassembler/script_disassembler.py')
| -rw-r--r-- | tools/script_disassembler/script_disassembler.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tools/script_disassembler/script_disassembler.py b/tools/script_disassembler/script_disassembler.py index 39390241..62f85f4c 100644 --- a/tools/script_disassembler/script_disassembler.py +++ b/tools/script_disassembler/script_disassembler.py @@ -120,10 +120,10 @@ commands = [ {'fun': 'sub_0807E898'}, {'fun': 'sub_0807E8C4', 'params': 'w'}, {'fun': 'sub_0807E8D4'}, - {'fun': 'sub_0807E8E4', 'params': ''}, - {'fun': 'sub_0807E8E4', 'params': ''}, - {'fun': 'sub_0807E8E4', 'params': ''}, - {'fun': 'sub_0807E8E4', 'params': ''}, + {'fun': 'sub_0807E8E4_0', 'params': ''}, # duplicate + {'fun': 'sub_0807E8E4_1', 'params': ''}, # duplicate + {'fun': 'sub_0807E8E4_2', 'params': ''}, # duplicate + {'fun': 'sub_0807E8E4_3', 'params': ''}, # duplicate {'fun': 'sub_0807E908'}, {'fun': 'sub_0807E914'}, {'fun': 'sub_0807E924'}, @@ -199,25 +199,25 @@ parameters = { 's': { 'length': 1, 'param': 's', - 'expr': 's,', + 'expr': 'asm(".short " #s);', 'read': lambda ctx: barray_to_u16_hex(ctx.data[ctx.ptr+2:ctx.ptr+4])[0] }, 'w': { 'length': 2, 'param': 'w', - 'expr': 'WORD_TO_SHORTS(w),', + 'expr': 'asm(".word " #w);', 'read': lambda ctx: barray_to_u32_hex(ctx.data[ctx.ptr+2:ctx.ptr+6])[0] }, 'ss': { 'length': 2, 'param': 'a,b', - 'expr': 'a,b,', + 'expr': 'asm(".short " #a);asm(".short " #b);', 'read': lambda ctx: ','.join(barray_to_u16_hex(ctx.data[ctx.ptr+2:ctx.ptr+6])) }, 'ww': { 'length': 4, 'param': 'a,b', - 'expr': 'WORD_TO_SHORTS(a), WORD_TO_SHORTS(b),', + 'expr': 'asm(".word " #a);asm(".word " #b);', 'read': lambda ctx: ','.join(barray_to_u32_hex(ctx.data[ctx.ptr+2:ctx.ptr+10])) }, } @@ -276,9 +276,9 @@ def generate_macros(): print('#ifndef SCRIPT_MACROS_H') print('#define SCRIPT_MACROS_H') print('// Generated by disassemble_script.py') - print('#define START_SCRIPT(name) const unsigned short name[] = {') - print('#define END_SCRIPT() };') - print('#define WORD_TO_SHORTS(word) (unsigned short)word & 0xffff,(unsigned short)word >> 16') + print('#define START_SCRIPT(name) asm(".globl "#name); asm(".section .rodata"); asm(#name":");') + print('#define END_SCRIPT()') + #print('#define WORD_TO_SHORTS(word) (unsigned short)word & 0xffff,(unsigned short)word >> 16') print('') for num, command in enumerate(commands): if not 'params' in command: @@ -289,7 +289,7 @@ def generate_macros(): params = parameters[command['params']] id = ((params['length']+1) << 0xA) + num - print('#define ' + command['fun'] + '(' + params['param'] + ') '+u16_to_hex(id)+', ' + params['expr']) + print('#define ' + command['fun'] + '(' + params['param'] + ') asm(".short '+u16_to_hex(id)+'");' + params['expr']) print ('#endif') |
