* Copyright (c) 2001, Paul Stoffregen, paul@pjrc.com
*
* This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
+ * modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
#ifdef FIELD_WIDTH
static bit field_width_flag;
+static bit leading_zero_flag;
static data unsigned char field_width;
#endif
clr _negative_flag
#ifdef FIELD_WIDTH
clr _field_width_flag
+ clr _leading_zero_flag
mov _field_width, #0
#endif
jnc printf_nondigit2
#ifdef FIELD_WIDTH
printf_digit:
+ jnz printf_digit_2
+ cjne a, _field_width, printf_digit_2
+ setb _leading_zero_flag
+printf_digit_2:
setb _field_width_flag
mov r1, a
mov a, _field_width
/* print a string... just grab each byte with __gptrget */
- /* the user much pass a 24 bit _generic pointer */
+ /* the user much pass a 24 bit generic pointer */
printf_string:
push dph // save addr in fmt onto stack
push dpl
- mov b, @r0 // b has type of address (_generic *)
+ mov b, @r0 // b has type of address (generic *)
dec r0
mov dph, @r0
dec r0
#ifdef FIELD_WIDTH
jnb _field_width_flag, printf_str_loop
+ clr _leading_zero_flag // never leading zeros for strings
push dpl
push dph
printf_str_fw_loop:
printf_space_loop:
//mov a, #' '
mov a, #32
+ jnb _leading_zero_flag, printf_space_output
+ //mov a, #'0'
+ mov a, #48
+printf_space_output:
lcall printf_putchar
dec _field_width
printf_space: