From 0e0876b17f9c40c5a5e18dd4b536911451d5cfc1 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Fri, 7 Oct 2022 16:04:02 +0200 Subject: [PATCH] Print addr ranges for empty blocks as well Mirrors what sections do, for clarity & consistency --- src/link/output.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/link/output.c b/src/link/output.c index 8a72cac7..18e2dac3 100644 --- a/src/link/output.c +++ b/src/link/output.c @@ -404,6 +404,16 @@ static void writeSymBank(struct SortedSections const *bankSections, } +static void writeEmptySpace(uint16_t begin, uint16_t end) +{ + if (begin < end) { + uint16_t len = end - begin; + + fprintf(mapFile, "\tEMPTY: $%04x-$%04x ($%04" PRIx16 " byte%s)\n", + begin, end - 1, len, len == 1 ? "" : "s"); + } +} + /* * Write a bank's contents to the map file * @param bankSections The bank's sections @@ -432,12 +442,7 @@ static uint16_t writeMapBank(struct SortedSections const *sectList, used += sect->size; assert(sect->offset == 0); - if (prevEndAddr < sect->org) { - uint16_t empty = sect->org - prevEndAddr; - - fprintf(mapFile, "\tEMPTY: $%04" PRIx16 " byte%s\n", empty, - empty == 1 ? "" : "s"); - } + writeEmptySpace(prevEndAddr, sect->org); prevEndAddr = sect->org + sect->size; @@ -474,19 +479,14 @@ static uint16_t writeMapBank(struct SortedSections const *sectList, uint16_t bankEndAddr = sectionTypeInfo[type].startAddr + sectionTypeInfo[type].size; - if (prevEndAddr < bankEndAddr) { - uint16_t empty = bankEndAddr - prevEndAddr; - - fprintf(mapFile, "\tEMPTY: $%04" PRIx16 " byte%s\n", empty, - empty == 1 ? "" : "s"); - } + writeEmptySpace(prevEndAddr, bankEndAddr); if (used == 0) { fputs(" EMPTY\n\n", mapFile); } else { uint16_t slack = sectionTypeInfo[type].size - used; - fprintf(mapFile, "\tSLACK: $%04" PRIx16 " byte%s\n\n", slack, + fprintf(mapFile, "\tTOTAL EMPTY: $%04" PRIx16 " byte%s\n\n", slack, slack == 1 ? "" : "s"); }