From 2fbdf974338bde8576efdae40a819a76b2391033 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sun, 5 Nov 2023 11:22:55 +0000 Subject: Initial import of the open source release --- tools/chksize | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 tools/chksize (limited to 'tools/chksize') diff --git a/tools/chksize b/tools/chksize new file mode 100755 index 0000000..147f4af --- /dev/null +++ b/tools/chksize @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +import sys + +# video memory - stack +TOP_MEM = 0xc000 - 256 + + +def main(): + if len(sys.argv) != 3: + sys.exit("usage: %s load_addr filename.map" % sys.argv[0]) + + load_addr = int(sys.argv[1]) + + with open(sys.argv[2], "r") as fd: + lines = fd.readlines() + # warnings + for line in lines: + if "l__INITIALIZED" in line: + init_size = int(line.split()[0], base=16) + if init_size != 0: + print("*WARNING* Initialized data found") + # search for HEAP + for line in lines: + if "s__HEAP" in line: + heap_addr = int(line.split()[0], base=16) + print("""\ +*** + Max: {} bytes + Current: {} bytes ({} bytes left) +*** +""".format(TOP_MEM - load_addr, heap_addr - load_addr, + TOP_MEM - heap_addr - load_addr)) + sys.exit(0) + + sys.exit("HEAP size not found") + + +if __name__ == "__main__": + main() -- cgit v1.2.3