github/workflows/pycopy-test: Upgrade Pycopy to 3.6.1.
[ScratchABlock.git] / obfuscate_pseudoc.py
blobea978d2324a890c53fef9da3577c0eada1c5f7dc
1 #!/usr/bin/env python3
2 import sys
3 import re
6 start_addr = None
7 out_f = None
10 with open(sys.argv[1]) as f:
11 for l in f:
12 addr = int(l[:8], 16)
13 l = l[8:]
15 if start_addr is None:
16 start_addr = addr
17 out_f = open("fun_%08x.lst" % (~start_addr & 0xffffffff), "w")
19 def repl(m):
20 return m.group(1) + "%08x" % (int(m.group(2), 16) - start_addr)
22 l = re.sub(r"(loc_)([0-9A-Fa-f]{8})", repl, l)
24 addr -= start_addr
25 out_f.write("%08x%s" % (addr, l))