Files
Cnomicon/src/libPIC/ser_putn.c
2021-01-22 10:16:20 -05:00

89 lines
2.5 KiB
C

/*****************************************************************************
* Copyright (C) 2008
* ProbeStar Telematics, LLC
* All Rights Reserved. Proprietary and Confidential.
*============================================================================
* Serial Number Output
*----------------------------------------------------------------------------
* Details
*****************************************************************************/
/*****************************************************************************
* includes
*****************************************************************************/
#include "serial.h"
#include "types.h"
/*****************************************************************************
* defines
*****************************************************************************/
/*****************************************************************************
* macros
*****************************************************************************/
/*****************************************************************************
* structs & typedefs
*****************************************************************************/
/*****************************************************************************
* global constants
*****************************************************************************/
/*****************************************************************************
* global variables
*****************************************************************************/
/*****************************************************************************
* static constants
*****************************************************************************/
/*****************************************************************************
* static variables
*****************************************************************************/
/*****************************************************************************
* static prototypes
*****************************************************************************/
/*****************************************************************************
* C functions
*****************************************************************************/
// warning, only does 8 digits
void putun( DWORD l )
{
BYTE i = 0;
DWORD o = 0;
while ( l )
{
o <<= 4;
o |= ( l % 10 );
l /= 10;
i++;
}
if ( i == 0 )
i++;
while ( i-- )
{
putch( (o & 0xf) + '0' );
o >>= 4;
}
putch( ' ' );
}
void putn( long n )
{
if ( n < 0 )
{
putch( '-' );
n = -n;
}
putun( n );
}