📄 fastmath.h
字号:
/*============================================================================
____________________________________________________________________________
______________________________________________
SSSS M M CCCC Standard Microsystems Corporation
S MM MM SSSS C Austin Design Center
SSS M M M S C 11000 N. Mopac Expressway
S M M SSS C Stonelake Bldg. 6, Suite 500
SSSS M M S CCCC Austin, Texas 78759
SSSS ______________________________________________
____________________________________________________________________________
Copyright(C) 1999, Standard Microsystems Corporation
All Rights Reserved.
This program code listing is proprietary to SMSC and may not be copied,
distributed, or used without a license to do so. Such license may have
Limited or Restricted Rights. Please refer to the license for further
clarification.
____________________________________________________________________________
Notice: The program contained in this listing is a proprietary trade
secret of SMSC, Hauppauge, New York, and is copyrighted
under the United States Copyright Act of 1976 as an unpublished work,
pursuant to Section 104 and Section 408 of Title XVII of the United
States code. Unauthorized copying, adaption, distribution, use, or
display is prohibited by this law.
____________________________________________________________________________
Use, duplication, or disclosure by the Government is subject to
restrictions as set forth in subparagraph(c)(1)(ii) of the Rights
in Technical Data and Computer Software clause at DFARS 52.227-7013.
Contractor/Manufacturer is Standard Microsystems Corporation,
80 Arkay Drive, Hauppauge, New York, 1178-8847.
____________________________________________________________________________
____________________________________________________________________________
fastmath.h - macros to do quick arithmetic w/o calling a slow library
____________________________________________________________________________
comments tbd
____________________________________________________________________________
Revision History
Date Who Comment
________ ___ _____________________________________________________________
10/15/01 cds initial version
01/15/02 cds updated 16-bit fast-math functions to work with t_uw16 struct
11/05/02 cds added bit_count8/16 functions
============================================================================*/
//------------------------------------------------------------------------------
// helpful macros for converting cdbs to 16 & 32 bit values
#define _uint16(h,l) ((uint16)((((uint16)(h))<<8)|(((uint16)(l)))))
#define _uint32(hh,hl,lh,ll) ((((uint32)(_uint16(hh,hl)))<<16)|((uint32)(_uint16(lh,ll))))
#define _hw(dw) ((uint16)((uint32)dw>>(uint32)16))
#define _lw(dw) ((uint16)((uint32)dw&0x0000ffff))
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
#define _u32_equ_0(val32) (0==(val32.u8.hi|val32.u8.lh|val32.u8.hl|val32.u8.lo))
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
#define _u32_equ(lhs, rhs) (0==((lhs.u8.hi^rhs.u8.hi)|(lhs.u8.lh^rhs.u8.lh)|(lhs.u8.hl^rhs.u8.hl)|(lhs.u8.lo^rhs.u8.lo)))
//------------------------------------------------------------------------------
// still slow
//------------------------------------------------------------------------------
#define _u32_lt(lhs, rhs) ((lhs.u32)<(rhs.u32))
//------------------------------------------------------------------------------
// still slow
//------------------------------------------------------------------------------
#define _u32_gt(lhs, rhs) ((lhs.u32)>(rhs.u32))
//------------------------------------------------------------------------------
// still slow
//------------------------------------------------------------------------------
#define _u32_dec(val32) ((val32.u32--))
//------------------------------------------------------------------------------
// still slow
//------------------------------------------------------------------------------
#define _u32_inc(val32) ((val32.u32++))
//------------------------------------------------------------------------------
// 16-bit compare against 0
// inclusive-or the 8-bit components
//------------------------------------------------------------------------------
#define _u16_equ_0(val16) (0==(val16.u8.lo|val16.u8.hi))
//------------------------------------------------------------------------------
// compare 2 16bit values for equality
// exclusive-or the 8-bit components, check for 0.
//------------------------------------------------------------------------------
#define _u16_equ(lhs, rhs) (0==((lhs.u8.lo^rhs.u8.lo)|(lhs.u8.hi^rhs.u8.hi)))
//------------------------------------------------------------------------------
// still slow
//------------------------------------------------------------------------------
#define _u16_lt(lhs, rhs) ((lhs.u16)<(rhs.u16))
//------------------------------------------------------------------------------
// still slow
//------------------------------------------------------------------------------
#define _u16_gt(lhs, rhs) ((lhs.u16)>(rhs.u16))
//------------------------------------------------------------------------------
// still slow
//------------------------------------------------------------------------------
#define _u16_dec(val16) ((val16.u8.hi-=(val16.u8.lo--?0:1)))
//------------------------------------------------------------------------------
// still slow
//------------------------------------------------------------------------------
#define _u16_inc(val16) ((val16.u8.hi+=(++val16.u8.lo?0:1)))
//+-----------------------------------------------------------------------------
// Name:
// bit_count8()
//
// Declaration:
// t_result bit_count8(void) reentrant ;
//
// Purpose:
// Count # of bits in a 8-bit value
//
// Arguments:
// val - 8-bit value in which to count bits
//
// Return:
// 0-8, depending on the number of bits set in 'val'
// Notes:
//
// Since:
// fmc-1.0
//------------------------------------------------------------------------------
uint8 bit_count8(uint8 val) reentrant;
//+-----------------------------------------------------------------------------
// Name:
// TBD
//
// Declaration:
// TBD
//
// Purpose:
// Count # of bits in a 16-bit value
//
// Arguments:
// val - 16-bit value in which to count bits
//
// Return:
// 0-16, depending on the number of bits set in 'val'
// Notes:
//
// Since:
// fmc-1.0
//------------------------------------------------------------------------------
uint8 bit_count16(uint16 val) reentrant;
//---eof------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -