From 2f60e0a59ee72647d223c86d246a8ca4893c133f Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sun, 9 Feb 2020 16:06:30 +0100 Subject: [PATCH] Use meaningful types for byte output functions --- include/asm/section.h | 4 ++-- src/asm/asmy.y | 2 +- src/asm/section.c | 12 +++++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/asm/section.h b/include/asm/section.h index ef998783..efc90967 100644 --- a/include/asm/section.h +++ b/include/asm/section.h @@ -26,8 +26,8 @@ struct Section *out_FindSectionByName(const char *pzName); void out_NewSection(char const *pzName, uint32_t secttype, int32_t org, struct SectionSpec const *attributes); -void out_AbsByte(int32_t b); -void out_AbsByteGroup(char const *s, int32_t length); +void out_AbsByte(uint8_t b); +void out_AbsByteGroup(uint8_t const *s, int32_t length); void out_Skip(int32_t skip); void out_String(char const *s); void out_RelByte(struct Expression *expr); diff --git a/src/asm/asmy.y b/src/asm/asmy.y index 24f06079..208e80e6 100644 --- a/src/asm/asmy.y +++ b/src/asm/asmy.y @@ -1137,7 +1137,7 @@ constlist_8bit_entry : /* empty */ char *s = $1; int32_t length = charmap_Convert(&s); - out_AbsByteGroup(s, length); + out_AbsByteGroup((uint8_t*)s, length); free(s); } ; diff --git a/src/asm/section.c b/src/asm/section.c index 1379adf6..2a151551 100644 --- a/src/asm/section.c +++ b/src/asm/section.c @@ -199,9 +199,8 @@ void out_NewSection(char const *pzName, uint32_t secttype, int32_t org, /* * Output an absolute byte (bypassing ROM/union checks) */ -static void absByteBypassCheck(int32_t b) +static void absByteBypassCheck(uint8_t b) { - b &= 0xFF; pCurrentSection->tData[nPC] = b; pCurrentSection->nPC++; nPC++; @@ -210,14 +209,14 @@ static void absByteBypassCheck(int32_t b) /* * Output an absolute byte */ -void out_AbsByte(int32_t b) +void out_AbsByte(uint8_t b) { checkcodesection(); checksectionoverflow(1); absByteBypassCheck(b); } -void out_AbsByteGroup(char const *s, int32_t length) +void out_AbsByteGroup(uint8_t const *s, int32_t length) { checkcodesection(); checksectionoverflow(length); @@ -278,11 +277,10 @@ void out_RelByte(struct Expression *expr) /* * Output an absolute word */ -static void absWord(int32_t b) +static void absWord(uint16_t b) { checkcodesection(); checksectionoverflow(2); - b &= 0xFFFF; pCurrentSection->tData[nPC] = b & 0xFF; pCurrentSection->tData[nPC + 1] = b >> 8; pCurrentSection->nPC += 2; @@ -312,7 +310,7 @@ void out_RelWord(struct Expression *expr) /* * Output an absolute longword */ -static void absLong(int32_t b) +static void absLong(uint32_t b) { checkcodesection(); checksectionoverflow(sizeof(int32_t));