From 43c4c16a40ec9c180ccf9ff2ed178900ed45d0b8 Mon Sep 17 00:00:00 2001 From: Jeroen Venema Date: Sat, 9 Nov 2024 13:49:33 +0100 Subject: [PATCH] Fix for issue #89 --- src/io.c | 9 ++++++--- src/listing.c | 39 +++++++++++++++++++++++++++++---------- src/listing.h | 1 + 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/io.c b/src/io.c index cc718c40..516df385 100644 --- a/src/io.c +++ b/src/io.c @@ -193,9 +193,12 @@ void io_close(void) { void emit_8bit(uint8_t value) { if(pass == 2) { - while(remaining_dsspaces) { - io_outputc(fillbyte); - remaining_dsspaces--; + if(remaining_dsspaces) { + if(list_enabled || consolelist_enabled) listPrintDSLines(remaining_dsspaces, fillbyte); + while(remaining_dsspaces) { + io_outputc(fillbyte); + remaining_dsspaces--; + } } if(list_enabled || consolelist_enabled) listEmit8bit(value); io_outputc(value); diff --git a/src/listing.c b/src/listing.c index 217061d1..ae7baca7 100644 --- a/src/listing.c +++ b/src/listing.c @@ -9,7 +9,8 @@ uint8_t _listLineObjectCount; uint16_t _listLineNumber; uint24_t _listSourceLineNumber; -char _listHeader[] = "PC Output Line\n\r"; +char _listHeader[] = "PC Output Line\n\r"; +char _listDataHeader[] = " "; char buffer[(LINEMAX * 2) + 1]; @@ -30,6 +31,26 @@ void listStartLine(char *line, unsigned int linenumber) { _listLineNumber = 0; } +void listPrintDSLines(int number, int value) { + while(number) { + uint8_t i = 0; + if(list_enabled) io_puts(FILE_LISTING, _listDataHeader); + if(consolelist_enabled) printf("%s",_listDataHeader); + + while(i < LISTING_OBJECTS_PER_LINE) { + if(number) { + sprintf(buffer, "%02X ",value); + if(list_enabled) io_puts(FILE_LISTING, buffer); + if(consolelist_enabled) printf("%s",buffer); + number--; + } + i++; + } + if(list_enabled) io_puts(FILE_LISTING, "\r\n"); + if(consolelist_enabled) printf("\r\n"); + } +} + void listPrintLine(void) { uint8_t i,spaces; @@ -39,9 +60,8 @@ void listPrintLine(void) { if(consolelist_enabled) printf("%s",buffer); } else { - sprintf(buffer, " "); - if(list_enabled) io_puts(FILE_LISTING, buffer); - if(consolelist_enabled) printf("%s",buffer); + if(list_enabled) io_puts(FILE_LISTING, _listDataHeader); + if(consolelist_enabled) printf("%s", _listDataHeader); } for(i = 0; i < _listLineObjectCount; i++) { sprintf(buffer, "%02X ",_listObjects[i]); @@ -70,15 +90,14 @@ void listPrintLine(void) { } if(list_enabled) io_puts(FILE_LISTING, buffer); if(consolelist_enabled) printf("%s",buffer); - sprintf(buffer, "%s\r\n", _listLine); - if(list_enabled) io_puts(FILE_LISTING, buffer); - if(consolelist_enabled) printf("%s",buffer); - } - else { - sprintf(buffer, "\r\n"); + sprintf(buffer, "%s", _listLine); if(list_enabled) io_puts(FILE_LISTING, buffer); if(consolelist_enabled) printf("%s",buffer); } + + if(list_enabled) io_puts(FILE_LISTING, "\r\n"); + if(consolelist_enabled) printf("\r\n"); + _listLineObjectCount = 0; _listLineNumber++; } diff --git a/src/listing.h b/src/listing.h index 7e5a6ab2..5d7c53a3 100644 --- a/src/listing.h +++ b/src/listing.h @@ -12,6 +12,7 @@ void listInit(void); void listStartLine(char *line, unsigned int linenumber); void listEndLine(void); +void listPrintDSLines(int number, int value); void listEmit8bit(uint8_t value); #endif // LISTING_H