From: Dan White Date: Mon, 29 Apr 2013 18:41:26 +0000 (-0500) Subject: add RCF generator for ROM fix X-Git-Tag: bootrom-initial-submission~22^2~1 X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=cf23fb5dd6bd8a21003a44c66801bf4d0c8c2aa3;p=430.git add RCF generator for ROM fix --- diff --git a/make-romfix.sh b/make-romfix.sh new file mode 100755 index 0000000..c23c445 --- /dev/null +++ b/make-romfix.sh @@ -0,0 +1,11 @@ +#!/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 + diff --git a/romasm2rcf.py b/romasm2rcf.py new file mode 100755 index 0000000..37b939b --- /dev/null +++ b/romasm2rcf.py @@ -0,0 +1,59 @@ +#! /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) +