X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device%2Flib%2Fvprintf.c;h=88ac993bae9f3d39892b3cdaafec596ce0e90ec9;hb=604f0a48a1db36000a837cfd490010ae3795e237;hp=12a7cdb88a2aff6e39eb1cda58083959f1d5140c;hpb=b09af35f2f1cde7649d3ac4a6f5d2af6d97895a0;p=fw%2Fsdcc diff --git a/device/lib/vprintf.c b/device/lib/vprintf.c index 12a7cdb8..88ac993b 100644 --- a/device/lib/vprintf.c +++ b/device/lib/vprintf.c @@ -27,14 +27,16 @@ #include #include -extern void putchar(const char); - #define PTR value.p /****************************************************************************/ typedef char _generic *ptr_t; +#ifdef toupper +#undef toupper +#endif + //#define toupper(c) ((c)&=~0x20) #define toupper(c) ((c)&=0xDF) @@ -235,11 +237,23 @@ get_conversion_spec: case 'P': PTR = va_arg(ap,ptr_t); +#ifdef SDCC_MODEL_FLAT24 + output_char(memory_id[(value.byte[3] > 3) ? 4 : value.byte[3]] ); + output_char(':'); + output_char('0'); + output_char('x'); + output_2digits(value.byte[2]); + output_2digits(value.byte[1]); + output_2digits(value.byte[0]); +#else output_char( memory_id[(value.byte[2] > 3) ? 4 : value.byte[2]] ); - output_char( ':' ); - if ((value.byte[2] != 0x00) && (value.byte[2] != 0x03)) + output_char(':'); + output_char('0'); + output_char('x'); + if ((value.byte[2] != 0x00 /* DSEG */) && (value.byte[2] != 0x03 /* SSEG */)) output_2digits( value.byte[1] ); output_2digits( value.byte[0] ); +#endif break; case 'D': @@ -306,9 +320,9 @@ get_conversion_spec: length=0; lsd = 1; - while( (value.byte[0] != 0) || (value.byte[1] != 0) || - (value.byte[2] != 0) || (value.byte[3] != 0) ) - { + + //jwk20000814: do this at least once, e.g.: printf ("%d", (int)0); + do { value.byte[4] = 0; calculate_digit(); @@ -328,8 +342,9 @@ _endasm; length++; lsd = ~lsd; - } - + } while( (value.byte[0] != 0) || (value.byte[1] != 0) || + (value.byte[2] != 0) || (value.byte[3] != 0) ); + if (width == 0) { // default width. We set it to 1 to output