--- /dev/null
+
+
+%.hex: %.rcf
+ ./rcf2ihex.py $< > $@
+
+%.asm: %.hex ns430-atoi.inc
+ msp430-objdump --disassemble-all --architecture=msp:54 $< \
+ | ./inc2syms.py ns430-atoi.inc | ./rename_regs.sh > $@
+
+%.h: %.mmap
+ ./mmap2h.sh $< > $@
+
+%.inc: %.mmap
+ ./mmap2inc.sh $< > $@
+
--- /dev/null
+#!/usr/bin/env python
+
+import sys
+
+VERBOSE = False
+
+if len(sys.argv) < 2 or sys.argv[1] == '-h':
+ print>>sys.stderr, 'Usage: %s syms.inc [file.asm]'
+ sys.exit(1)
+
+incfile = open(sys.argv[1])
+
+if len(sys.argv) == 2:
+ asmfile = sys.stdin
+else:
+ asmfile = open(sys.argv[2])
+
+
+syms = {}
+addrs = {}
+print 'Symbol Table:'
+for line in incfile:
+ if 'equ' in line:
+ sp = line.strip().split()
+ syms[sp[0]] = '0x' + sp[2][:-1]
+ addrs[syms[sp[0]]] = sp[0]
+ print ' %s: %s' % (sp[0], syms[sp[0]])
+
+
+lines = asmfile.readlines()
+
+newlines = []
+for line in lines:
+ oldline = line
+ replaced = False
+ for addr in addrs.iterkeys():
+ if addr in line:
+ line = line.replace(addr, addrs[addr])
+ if VERBOSE:
+ if replaced:
+ print>>sys.stderr, '*** double replacement !!!'
+ print>>sys.stderr, 'old:', oldline.rstrip()
+ print>>sys.stderr, 'new:', line.rstrip()
+ replaced = True
+
+ newlines.append(line)
+
+print ''.join(newlines)
+#sys.stdout.write(''.join(newlines))
--- /dev/null
+#!/bin/bash
+
+# Extract header definitions from the memory map
+# e.g. #FOO_NAME = 4002h
+# transform to C-style #define's
+egrep -o '#.*' $1 \
+ | cut -c 2- \
+ | tr -d =h \
+ | awk '{print "#define " $1 " 0x" $2}'
+
--- /dev/null
+#!/bin/bash
+
+# Extract header definitions from the memory map
+# e.g. #FOO_NAME = 4002h
+# transform to assembler equ's
+egrep -o '#.*' $1 \
+ | cut -c 2- \
+ | tr -d = \
+ | awk '{print $1 " equ " $2}'
+
--- /dev/null
+#!/usr/bin/env python
+
+import sys
+
+if len(sys.argv) < 2:
+ print>>sys.stderr, 'Usage %s rom.rcf' % sys.argv[0]
+ sys.exit(1)
+
+#rcf = open('rom.rcf')
+rcf = open(sys.argv[1])
+#ihex = open('rom.hex', 'w')
+ihex = sys.stdout
+
+start_addr = int('3000', 16)
+
+bytes = []
+for line in rcf:
+ word = line.strip()
+ b1 = int(word[0:8], 2)
+ b0 = int(word[8:], 2)
+
+ bytes.append(b0)
+ bytes.append(b1)
+
+
+def checksum(vec):
+ s = sum(vec)
+ c = s & 0xFF
+ c ^= 0xFF
+ c += 1
+ c &= 0xFF
+ return c
+ #return -sum(vec) & 0xFF
+
+
+#v = [0,0,0,0,0]
+#print checksum(v), (sum(v)+checksum(v)) & 0xFF
+#v = [2,2,2,2,2]
+#print checksum(v), (sum(v)+checksum(v)) & 0xFF
+#v = [0,1,2,3,240]
+#print checksum(v), (sum(v)+checksum(v)) & 0xFF
+
+
+
+# count, addr, type, hexstring, checksum
+ihex_fmt = ':%02X%04X%02X%s%02X'
+nbytes = 16
+addr = start_addr
+for i in range(len(bytes)/nbytes + 1):
+ bvec = bytes[i*nbytes:(i+1)*nbytes]
+
+ if not bvec: break
+
+ sumvec = [len(bvec), ((addr >> 8) & 0xFF), (addr & 0xFF), 0]
+ sumvec.extend(bvec)
+ cs = checksum(sumvec)
+
+ bstr = ''.join(['%02X' % b for b in bvec])
+
+ print >>ihex, ihex_fmt % (16, addr, 0, bstr, cs)
+
+ addr += nbytes
+
+print >>ihex, ':00000001FF'
+
--- /dev/null
+#!/bin/bash
+
+sed -r -e 's/[^;]r0([ \t,\)])/pc\1/g' \
+ -e 's/[^;]r1([ \t,\)])/sp\1/g' \
+ -e 's/[^;]r2([ \t,\)])/sr\1/g'
+