From 8a104a613fdefe4d38547a26248325eeb0fd601d Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Sun, 19 Nov 2023 21:42:07 +0100 Subject: [PATCH 1/2] Fix error code returned to the OS in crt0_msxdos_advanced. It was being taken from register L, but in newer SDCCs it's passed in register A instead. --- source/tools/C/crt0_msxdos_advanced.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/tools/C/crt0_msxdos_advanced.s b/source/tools/C/crt0_msxdos_advanced.s index 515a3751..e7b87a6f 100644 --- a/source/tools/C/crt0_msxdos_advanced.s +++ b/source/tools/C/crt0_msxdos_advanced.s @@ -129,7 +129,7 @@ cont: ld hl,#0x100 ; Termination code for DOS 2 was returned on L. ld c,#0x62 ;DOS 2 function for program termination (_TERM) - ld b,l + ld b,a call 5 ;On DOS 2 this terminates; on DOS 1 this returns... ld c,#0x0 jp 5 ;...and then this one terminates From b9a0176bb4423fb0bd13cbf680d1086947baee97 Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Sun, 19 Nov 2023 21:44:29 +0100 Subject: [PATCH 2/2] Fixes in long integer handling in printf.c - Doc comment fixed: now it correctly says that the modifier for integers is "u" (not "ud" or "ui") and for unsigned long is "lu" (not "ul") - Fixed the "l" modifier, it was skipping the next character --- source/tools/C/printf.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/tools/C/printf.c b/source/tools/C/printf.c index dc719838..0cd87eba 100644 --- a/source/tools/C/printf.c +++ b/source/tools/C/printf.c @@ -11,7 +11,7 @@ Supported format specifiers: %d or %i: signed int - %ud or %ui: unsigned int + %u: unsigned int %x: hexadecimal int %c: character %s: string @@ -20,7 +20,7 @@ Also if SUPPORT_LONG is defined: %l: signed long - %ul: unsigned long + %lu: unsigned long %lx: hexadecimal long */ @@ -160,7 +160,12 @@ static int format_string(const char* buf, const char *fmt, va_list ap) else if(theChar == 'x') { base = 16; } - else if(theChar != 'd' && theChar != 'i') { +#ifdef SUPPORT_LONG + else if(isLong) { + fmtPnt--; + } else +#endif + if(theChar != 'd' && theChar != 'i') { do_char_inc(theChar); continue; }