--- /dev/null
+#!/bin/bash
+
+./romasm2rcf.py rom-bugfix.asm > rom-bugfix.rcf
+./rcf2ihex.py rom-bugfix.rcf > rom-bugfix.hex
+
+
+echo "********* RCF differences *********"
+diff -u rom.rcf rom-bugfix.rcf
+echo "***********************************"
+echo
+
--- /dev/null
+#! /usr/bin/env python
+
+
+import sys
+from collections import defaultdict
+
+
+
+infile = 'rom-bugfix.asm'
+
+# unused ROM words default to this value
+addresses = defaultdict(lambda: 0)
+
+# trailing bytes (typ. after a string) should be this value
+empty_byte = 0
+
+
+def binword(w, width=16):
+ """Return a width-length, left-zero-padded bit string binary representation
+ of the integer w."""
+ b = bin(w)
+ b = b.lstrip('0b')
+ return ('0' * (width - len(b))) + b
+
+
+#for line in open(sys.argv[1]):
+for line in open(infile):
+ line.strip()
+
+ if line.startswith(';'):
+ continue
+
+ sp = line.split()
+
+ if (len(sp) > 0) and sp[0].endswith(':'):
+ #is this a label?
+ try:
+ addr = int(sp[0][0:4], 16)
+ except ValueError:
+ continue
+
+
+ addresses[addr] = int(sp[1], 16)
+
+ # collect the next bytes, if present
+ for i in (1, 2, 3):
+ try:
+ data = int(sp[i+1], 16)
+ except (IndexError, ValueError):
+ continue
+
+ addresses[addr + i] = data
+
+
+# dump all the ROM addresses
+for addr in range(0x3000, 0x4000, 2):
+ word = (addresses[addr+1] << 8) + addresses[addr]
+ print binword(word)
+