summaryrefslogtreecommitdiff
path: root/tools/chksize
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2020-12-30 19:07:31 +0000
committerJuan J. Martinez <jjm@usebox.net>2020-12-30 19:23:41 +0000
commit2682bc5d1d864341aaeb42a449db73c3ecd16d70 (patch)
tree9116764364b4ee0ce7f6037305077807b57776de /tools/chksize
downloadubox-msx-lib-2682bc5d1d864341aaeb42a449db73c3ecd16d70.tar.gz
ubox-msx-lib-2682bc5d1d864341aaeb42a449db73c3ecd16d70.zip
Initial import1.0
Diffstat (limited to 'tools/chksize')
-rwxr-xr-xtools/chksize30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/chksize b/tools/chksize
new file mode 100755
index 0000000..f7c2d41
--- /dev/null
+++ b/tools/chksize
@@ -0,0 +1,30 @@
+#!/usr/bin/env python3
+
+import sys
+
+TOP_MEM = 0xc000 - 256 # video memory - stack
+
+
+def main():
+ if len(sys.argv) != 4:
+ sys.exit("usage: %s code_limit_hex data_limit_hex filename.map" %
+ sys.argv[0])
+
+ sizes = {"CODE": 0, "DATA": 0}
+
+ with open(sys.argv[3], "r") as fd:
+ for line in fd.readlines():
+ for seg in sizes.keys():
+ if "l__%s" % seg in line:
+ sizes[seg] = int(line.split()[0], base=16)
+
+ print("\nROM: %(CODE)05d bytes\nRAM: %(DATA)05d bytes\n" % sizes)
+
+ if sizes["CODE"] > int(sys.argv[1], 16):
+ sys.exit("ROM is over the limit")
+ if sizes["DATA"] > int(sys.argv[2], 16):
+ sys.exit("RAM is over the limit")
+
+
+if __name__ == "__main__":
+ main()