X-Git-Url: https://git.gag.com/?a=blobdiff_plain;ds=sidebyside;f=device%2Flib%2Fprintf_tiny.c;h=0ebded46115da41f7600453ac15a711fa04a74d2;hb=d446cb1283ca88e68db9054d33921ef96bedbf29;hp=4db9fe4fcfc78b269ffec436d41091143523f346;hpb=5689c6b6b4499a51a342499e09bd58529b1d89ae;p=fw%2Fsdcc diff --git a/device/lib/printf_tiny.c b/device/lib/printf_tiny.c index 4db9fe4f..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 @@ -61,16 +61,19 @@ #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 +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) @@ -128,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 @@ -136,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 @@ -281,9 +285,8 @@ printf_ret: printf_end: - _endasm; + __endasm; } #endif // defines compatible with printf_tiny -