- case 'O':
- radix = 8;
- break;
-
- case 'U':
- radix = 10;
- break;
-
- case 'X':
- radix = 16;
- break;
-
- case 'F':
- float_argument=1;
- break;
-
- default:
- // nothing special, just output the character
- output_char( c );
- break;
- }
-
- if (float_argument) {
- value.f=va_arg(ap,float);
-#if !USE_FLOATS
- PTR="<NO FLOAT>";
- while (c=*PTR++)
- output_char (c);
- // treat as long hex
- //radix=16;
- //long_argument=1;
- //zero_padding=1;
- //width=8;
-#else
- // ignore b and l conversion spec for now
- output_float(value.f, width, decimals, left_justify, zero_padding,
- prefix_sign, prefix_space);
-#endif
- } else if (radix != 0)
- {
- // Apperently we have to output an integral type
- // with radix "radix"
-
- // store value in byte[0] (LSB) ... byte[3] (MSB)
- if (char_argument)
- {
- value.l = va_arg(ap,char);
- if (!signed_argument)
- {
- value.byte[1] = 0x00;
- value.byte[2] = 0x00;
- value.byte[3] = 0x00;
- }
- }
- else if (long_argument)
- {
- value.l = va_arg(ap,long);
- }
- else // must be int
- {
- value.l = va_arg(ap,int);
- if (!signed_argument)
- {
- value.byte[2] = 0x00;
- value.byte[3] = 0x00;
- }
- }
-
- if ( signed_argument )
- {
- if (value.l < 0)
- value.l = -value.l;
- else
- signed_argument = 0;
- }
-
- length=0;
- lsd = 1;
-
- //jwk20000814: do this at least once, e.g.: printf ("%d", (int)0);
- do {
- value.byte[4] = 0;
- calculate_digit();
-
-_asm
- jb _lsd,1$
- pop b ; b = <lsd>
- mov a,_value+4 ; a = <msd>
- swap a
- orl b,a ; b = <msd><lsd>
- push b
- sjmp 2$
-1$:
- mov a,_value+4 ; a = <lsd>
- push acc
-2$:
-_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
- // at least one character is case the value itself
- // is zero (i.e. length==0)
- width=1;
- }
-
- /* prepend spaces if needed */
- if (!zero_padding)
- {
- while ( width > length+1 )
- {
- output_char( ' ' );
- width--;
- }
- }
-
- if (signed_argument) // this now means the original value was negative
- {
- output_char( '-' );
- // adjust width to compensate for this character
- width--;
- }
- else if (length != 0)
- {
- // value > 0
- if (prefix_sign)
- {
- output_char( '+' );
- // adjust width to compensate for this character
- width--;
- }
- else if (prefix_space)
- {
- output_char( ' ' );
- // adjust width to compensate for this character
- width--;
- }
- }
-
- /* prepend zeroes/spaces if needed */
- while ( width-- > length )
- {
- output_char( zero_padding ? '0' : ' ' );
- }
-
- /* output the digits */
- while( length-- )
- {
- lsd = ~lsd;
-
-_asm
- jb _lsd,3$
- pop acc ; a = <msd><lsd>
- nop ; to disable the "optimizer"
- push acc
- swap a
- anl a,#0x0F ; a = <msd>
- sjmp 4$
-3$:
- pop acc
- anl a,#0x0F ; a = <lsd>
-4$:
- mov _value+4,a
-_endasm;
-
- output_digit( value.byte[4] );
- }
- }
- }
- else
- {
- // nothing special, just output the character
- output_char( c );
- }
- }
-
- // Copy \0 to the end of buf
- // Modified by JB 17/12/99
- if (output_to_string) {
- output_char(0);
- return charsOutputted-1;
- } else {
- return charsOutputted;
- }
-}
-
-/*--------------------------------------------------------------------------*/
-
-int vprintf (const char *format, va_list ap)
-{
- return vsprintf( 0, format, ap );