From 0254577c969a2b94280c51ee5fd0965226b3ca73 Mon Sep 17 00:00:00 2001 From: Lawrence Kesteloot Date: Tue, 31 Jul 2018 16:05:56 -0700 Subject: [PATCH] AWK script to dump ROM size info. --- Makefile | 1 + rom_usage.awk | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 rom_usage.awk diff --git a/Makefile b/Makefile index d174260..0f33271 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ run: $(ROM) a.out: main.o interrupt.o vectors.o platform.o apple2rom.cfg $(LIB) $(CC65)/ld65 -C apple2rom.cfg -m main.map --dbgfile main.dbg interrupt.o vectors.o platform.o main.o $(LIB) + awk -f rom_usage.awk < main.map clean: rm -f *.o *.lst a.out platform.s main.s $(LIB) tmp.lib diff --git a/rom_usage.awk b/rom_usage.awk new file mode 100644 index 0000000..bcc2f26 --- /dev/null +++ b/rom_usage.awk @@ -0,0 +1,14 @@ +# Pipe main.map into this to get ROM size info. + +/^CODE/ { code_start = ("0x" $2) + 0 } + +/^RODATA/ { rodata_end = ("0x" $3) + 0 } + +/^VECTORS/ { vectors_start = ("0x" $2) + 0 } + +END { + code = rodata_end - code_start + 1 + all = vectors_start - code_start + printf "%d of %d ROM bytes (%d%%) used\n", code, all, code*100/all +} +