OpenCores
URL https://opencores.org/ocsvn/amber/amber/trunk

Subversion Repositories amber

[/] [amber/] [trunk/] [sw/] [boot-loader-ethmac/] [print.c] - Diff between revs 61 and 78

Show entire file | Details | Blame | View Log

Rev 61 Rev 78
Line 46... Line 46...
 
 
/* the following should be enough for 32 bit int */
/* the following should be enough for 32 bit int */
#define PRINT_BUF_LEN 16
#define PRINT_BUF_LEN 16
 
 
 
 
 
/* format and print a string, inserting variables, to dst char buffer,
 
   return the number of characters printed. If dst is 0, the string is
 
   sent to the serial output
 
*/
int print(char** dst, const char *format, unsigned long *varg)
int print(char** dst, const char *format, unsigned long *varg)
{
{
    register int width, pad;
    register int width, pad;
    register int pc = 0;
    register int pc = 0;
    char scr[2];
    char scr[2];
Line 102... Line 105...
             continue;
             continue;
          }
          }
       }
       }
       else {
       else {
       out:
       out:
          //outbyte (dst, *format);
          if (dst)
          *(*dst)++ = *format;
          *(*dst)++ = *format;
 
          else
 
              serial_putchar_(*format);
          ++pc;
          ++pc;
       }
       }
    }
    }
 
 
    return pc;
    return pc;
Line 127... Line 132...
       else width -= len;
       else width -= len;
       if (pad & PAD_ZERO) padchar = '0';
       if (pad & PAD_ZERO) padchar = '0';
    }
    }
    if (!(pad & PAD_RIGHT)) {
    if (!(pad & PAD_RIGHT)) {
       for ( ; width > 0; --width) {
       for ( ; width > 0; --width) {
          //outbyte(dst, padchar);              
          if (dst)
          *(*dst)++ = padchar;
          *(*dst)++ = padchar;
 
          else
 
              serial_putchar_(padchar);
          ++pc;
          ++pc;
       }
       }
    }
    }
    for ( ; *string ; ++string) {
    for ( ; *string ; ++string) {
       //outbyte(dst, *string);                 
       if (dst)
       *(*dst)++ = *string;
       *(*dst)++ = *string;
 
       else
 
          serial_putchar_(*string);
       ++pc;
       ++pc;
    }
    }
    for ( ; width > 0; --width) {
    for ( ; width > 0; --width) {
       //outbyte(dst, padchar);                 
       if (dst)
       *(*dst)++ = padchar;
       *(*dst)++ = padchar;
 
       else
 
          serial_putchar_(padchar);
       ++pc;
       ++pc;
    }
    }
 
 
    return pc;
    return pc;
}
}
Line 184... Line 195...
       else           u = _div(u, b);
       else           u = _div(u, b);
    }
    }
 
 
    if (neg) {
    if (neg) {
       if( width && (pad & PAD_ZERO) ) {
       if( width && (pad & PAD_ZERO) ) {
          //outbyte(dst,'-'); 
          if (dst)
          *(*dst)++ = '-';
          *(*dst)++ = '-';
 
          else
 
              serial_putchar_('-');
          ++pc;
          ++pc;
          --width;
          --width;
       }
       }
       else {
       else {
          *--s = '-';
          *--s = '-';

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.