From cf01b391440fc9de43597b907acfc22dba1aa15e Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 18 Jun 2017 14:38:03 +0200 Subject: Add j1 --- j1 | 1 - j1/toolchain/dump.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) delete mode 160000 j1 create mode 100644 j1/toolchain/dump.py (limited to 'j1/toolchain/dump.py') diff --git a/j1 b/j1 deleted file mode 160000 index 9114396..0000000 --- a/j1 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 911439641c002a8f7a6e306ce1b1d3fd4b389fd6 diff --git a/j1/toolchain/dump.py b/j1/toolchain/dump.py new file mode 100644 index 0000000..283916b --- /dev/null +++ b/j1/toolchain/dump.py @@ -0,0 +1,36 @@ +import sys +import array + +def hexdump(s): + def toprint(c): + if 32 <= ord(c) < 127: + return c + else: + return "." + def hexline(i, s): + return ("%04x: " % i + " ".join(["%02x" % ord(c) for c in s]).ljust(52) + + "|" + + "".join([toprint(c) for c in s]).ljust(16) + + "|") + return "\n".join([hexline(i, s[i:i+16]) for i in range(0, len(s), 16)]) + +pgm = array.array('H', [int(l, 16) for l in open(sys.argv[1])]) + +while pgm[-1] == 0: + pgm = pgm[:-1] +s = pgm.tostring() +print +print hexdump(s) + +link = [w for w in pgm[::-1] if w][0] +words = [] +while link: + name = s[link + 2:] + c = ord(name[0]) + name = name[1:1+c] + print "%04x %s" % (link, name) + assert not name in words + words.append(name) + link = pgm[link / 2] +print len(words), " ".join(words) +print "program size %d/%d" % (len(pgm), 1024) -- cgit v1.2.3