Add some more scripts

This commit is contained in:
PikalaxALT 2021-08-12 17:45:10 -04:00
parent e60198dce9
commit 8cd986cc74
5 changed files with 80 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/

6
fix_ov.sh Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
OV=$1
echo "sed -r -f <(grep -wE \"(thumb|arm)_func_start\" overlays/${OV}/module_${OV}.dump.s | grep -oE \"\w+$\" | xargs | sed -r -e 's/ FUN_/|/g' -e 's/^(MOD'${OV}')_/s\/\(FUN\|\1\)_\(/' -e 's/$/\)\/ov'${OV}'_\\2\/g/') overlays/${OV}/module_${OV}.dump.s > overlays/${OV}/module_${OV}.s"
sed -r -f <(grep -wE "(thumb|arm)_func_start" overlays/${OV}/module_${OV}.dump.s | grep -oE "\w+$" | xargs | sed -r -e 's/ FUN_/|/g' -e 's/^(MOD'${OV}'|FUN)_/s\/\(FUN\|\1\)_\(/' -e 's/$/\)\/ov'${OV}'_\\2\/g/') overlays/${OV}/module_${OV}.dump.s > overlays/${OV}/module_${OV}.s

7
make_defs.sh Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
(head -c 44 baserom.nds | tail -c 4
head -c 40 baserom.nds | tail -c 4
head -c 48 baserom.nds | tail -c 4
head -c 116 baserom.nds | tail -c 4
sed -r '/^Overlay/!d' main.lsf | sed 's/Overlay //g' | while read ovname; do echo -ne "${ovname}.sbin\0"; done) > main_defs.sbin

39
sfix_arm.sed Normal file
View File

@ -0,0 +1,39 @@
## Common
# 4byte/2byte
s/4byte/word/
s/2byte/short/
# Comment chars
s/@/;/g
# blx instructions are added link-time
/blx (r[0-9]+|sb|sl|fp|ip|sp|lr|pc)/!s/blx/bl/
# swi
s/svc #?/swi /
## Arm-specific
# Conditional byte/half load/store insns
s/(ldr|str)(s?[bh])(\w{2})/\1\3\2/
# ldm/stm
s/(ldm|stm)([id][ab])(\w{2})/\1\3\2/
s/(ldm|stm)(eq|ne|cs|lo|hi|hs|lt|gt|le|ge)?\b/\1\2ia/
# Push/pop
s/push/stmdb sp!,/
s/pop(\w*)/ldm\1ia sp!,/
# Shift instructions
s/(lsl|lsr|asr|ror)(\w* .+,)( \S+)$/mov\2 \1\3/
s/rrx(.+)/mov\1, rrx/
# apsr --> cpsr
s/apsr/cpsr/i
s/cpsr_nzcvq/cpsr_f/i
# mcr/mrc
/(mcr|mrc)/s/#//g
# conditional and/orr/eor/bic
s/(add|sub|and|orr|eor|bic|mul)s(\w{2})/\1\2s/

27
sfix_thumb.sed Normal file
View File

@ -0,0 +1,27 @@
## Common
# 4byte/2byte
s/4byte/word/
s/2byte/short/
# Comment chars
s/@/;/g
# blx instructions are added link-time
/blx (r\d+|sb|sl|fp|ip|sp|lr|pc)/!s/blx/bl/
# swi
s/svc #?/swi /
## Thumb-specific
# Flag-setting instructions
s/(\t\w{3})s\b/\1/
# rsb instructions are not valid in mwasmarm
s/rsb (\w+, \w+), \#0/neg \1/
# ldm/stm must have the "ia" suffix
s/(ldm|stm)\b/\0ia/
s/((ldm|stm)ia \w+),/\1!,/
# mul arg syntax
s/(mul \w+, \w+), \w+/\1/