/* **********************************************************************
 * *                                                                    *
 * *             User Library, Kilo Count functions                     *
 * *                                                                    *
 * **********************************************************************
 * File: libs/user/KiloCount.c
 *
 *                        COPYRIGHT (c) 2003  BY
 *          SIGMET INCORPORATED, WESTFORD MASSACHUSETTS, U.S.A.
 * 
 * THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
 * ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
 * INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
 * COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
 * OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
 * TRANSFERED.
 */

#include "sigtypes.h"
#include "user_lib.h"

/* ======================================================================
 * Accumulate a 32-bit number into a kilo_count structure.
 */
void kilo_count_accum
(volatile struct kilo_count *kcnt_a,
 SINT4 ival_a)
{
  kcnt_a->iones &= 0x3FF ;		  /* Ignore possible junk */

  kcnt_a->iones += (ival_a & 0x3FF) ;	  /* Do the 42-bit addition */
  kcnt_a->ikilo += (ival_a >> 10) ;
  if( kcnt_a->iones & 0x400 ) kcnt_a->ikilo += 1 ;

  kcnt_a->iones &= 0x3FF ;		  /* Remove possible junk */
}


