X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device%2Flib%2Fprintf_tiny.c;h=0ebded46115da41f7600453ac15a711fa04a74d2;hb=870a9fb183ba31e7c17b253cd859cf1c6c886c2a;hp=4a6dfd4d9e265e9ed9f3d1fa6928a9f11d4875ac;hpb=705b7357c506ef25bf9e84dea2d1a9b4eefea251;p=fw%2Fsdcc diff --git a/device/lib/printf_tiny.c b/device/lib/printf_tiny.c index 4a6dfd4d..0ebded46 100644 --- a/device/lib/printf_tiny.c +++ b/device/lib/printf_tiny.c @@ -22,7 +22,7 @@ * interrupt routine). Code size is under 270 bytes. Only one library * function is called (_gptrget, 41 bytes), in addition to calls to * putchar(). - * + * * Five simple formats are supported * * %d signed 16 bit integer decimal (-32768 to 32767) @@ -33,7 +33,7 @@ * * For a more complete printf that supports longs, floating point and * field width, try using printf_fast() or printf_large(). - */ + */ // This removes the negative number code, causing "%d" to be the same @@ -54,11 +54,26 @@ #define print_zero_flag PSW.5 -void printf_tiny(code char *fmt, ...) reentrant +#if !defined(SDCC_mcs51) || defined(SDCC_USE_XSTACK) || defined(_SDCC_NO_ASM_LIB_FUNCS) +// Does printf_tiny really work on ds390 and ds400? +// If it does, enable them in the line above +#if defined(SDCC_USE_XSTACK) +#warning "printf_tiny not built, does not support --xstack" +#elif defined(_SDCC_NO_ASM_LIB_FUNCS) +#warning "printf_tiny not built, _SDCC_NO_ASM_LIB_FUNCS defined" +#else +/* Disable "ISO C forbids an empty source file" wraning message */ +#pragma disable_warning 190 +#endif +#else // defines are compatible with printf_tiny + + + +void printf_tiny(__code char *fmt, ...) __reentrant { - fmt; /* supress unreferenced variable warning */ + fmt; /* suppress unreferenced variable warning */ - _asm + __asm printf_begin: mov a, _bp // r0 will point to va_args (stack) @@ -116,6 +131,7 @@ printf_str_loop: printf_format_c: //cjne a, #'c', printf_format_d cjne a, #99, printf_format_d + dec r0 mov a, @r0 // Acc has the character to print dec r0 lcall printf_putchar @@ -124,7 +140,7 @@ printf_format_c: printf_format_d: //cjne a, #'d', printf_format_u - cjne a, #100, printf_format_u + cjne a, #100, printf_format_x #ifndef ALWAYS_PRINT_UNSIGNED mov a, @r0 jnb acc.7, printf_uint @@ -269,7 +285,8 @@ printf_ret: printf_end: - _endasm; + __endasm; } +#endif // defines compatible with printf_tiny