⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bitutilc.h

📁 arm ads1.2 with crack.rar
💻 H
📖 第 1 页 / 共 2 页
字号:
 * Outputs
 * -------
 *   ARRAY
 *   - the array of data items with any sign extension removed
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
#define REMOVESIGNEXTENDARRAY( ARRAY, SIZE, BITS ) { \
	int counter ; \
	for( counter = 0 ; counter < SIZE ; counter += 1 ) { \
		REMOVESIGNEXTEND( ARRAY[ counter ], BITS ) ; \
	} \
}

/**** REVERSEUNITS ******************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * given a word reverse the required bit-size units
 *
 * Inputs
 * ------
 *   WORD
 *   - the word to reverse bit-size units of
 *   REVERSED
 *   - a word to hold the unit reversed version of WORD
 *   MASK
 *   - a constant value that must contain one of
 *     0x0000FFFF	reverse units of 16-bits
 *     = (a,b)->(b,a)
 *	   0x00FF00FF	reverse units of 8-bits
 *     = (a,b,c,d)->(b,a,d,c)
 *     0x0F0F0F0F	reverse units of 4-bits
 *     = (a,b,c,d,e,f,g,h)->(b,a,d,c,f,e,h,g)
 *     0x33333333	reverse units of 2-bits
 *     = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)->(b,a,d,c,f,e,h,g,j,i,l,k,n,m,p,o)
 *     0x55555555	reverse units of 1-bit
 *     = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff)
 *     -> (b,a,d,c,f,e,h,g,j,i,l,k,n,m,p,o,r,q,t,s,v,u,x,w,z,y,bb,aa,dd,cc,ff,ee)
 *   BITS
 *   - a constant value that must be either 16, 8, 4, 2 or 1
 *     any other value, the returned value is undertermined
 * Outputs
 * -------
 *   REVERSED
 *   - the unit reversed version of WORD
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
#define REVERSEUNITS( WORD, REVERSED, MASK, BITS ) { \
	unsigned int	topBits ; \
	topBits = ( ( unsigned int )WORD >> BITS ) & ( unsigned int )MASK ; \
	REVERSED = ( unsigned int )WORD & ( unsigned int )MASK ; \
	REVERSED = topBits | ( ( unsigned int )REVERSED << BITS ) ; \
}

/**** ROR ***************************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * rotate right the given word by the given number of bits
 *
 * Inputs
 * ------
 *   WORD
 *   - the word to rotate right
 *   BITS
 *   - the number of bits to rotate by
 *   ROTATED
 *   - a word to hold the rotated word result
 * Outputs
 * -------
 *   ROTATED
 *   - the rotated word result
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
#define ROR( WORD, BITS, ROTATED ) { \
	if( ( BITS >= 0 ) && ( BITS <= 32 ) ) { \
		ROTATED = ( WORD << ( 32 - BITS ) ) | ( ( unsigned int )WORD >> BITS ) ; \
	} \
}

/**** SIGNEDSATURATION **************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * given two signed numbers, add them together saturating the result
 *
 * Inputs
 * ------
 *   NUMBER1, NUMBER2
 *   - the two signed numbers to add together
 *   SIGNSAT
 *   - an integer to hold the result of the signed saturated addition
 * Outputs
 * -------
 *   SIGNSAT
 *   - the result of the signed saturation addition
 *     if the result overflows the negative range, the result is 0x80000000
 *     if the result overflows the positive range, the result is 0x7FFFFFFF
 *     otherwise the result is the result of the addition
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
#define SIGNEDSATURATION( NUMBER1, NUMBER2, SIGNSAT ) { \
	int	sign = 0x80000000 ; \
	SIGNSAT = NUMBER1 + NUMBER2 ; \
	if( ( ( NUMBER1 & sign ) == ( NUMBER2 & sign ) ) \
		&& ( ( NUMBER1 & sign ) != ( SIGNSAT & sign ) ) ) { \
		SIGNSAT = sign ^ ( ( signed )SIGNSAT >> 31 ) ; \
	} \
}

/**** SIGNEXTEND ********************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * sign extend the given data value that is of the given number of bits in size
 *
 * Inputs
 * ------
 *   DATA
 *   - the data value to sign extend
 *   BITS
 *   - the size of the data in bits (including sign bit)
 * Outputs
 * -------
 *   DATA
 *   - the sign extended data
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
#define SIGNEXTEND( DATA, BITS ) { \
	int	mask = 0xFFFFFFFF ; \
	if( ( BITS > 0 ) && ( BITS < 32 ) ) { \
		if( ( int )DATA & ( 1 << ( BITS - 1 ) ) ) { \
			DATA = ( int )DATA | ( ( mask >> ( BITS - 1 ) ) << ( BITS - 1 )) ; \
		} \
	} \
}

/**** SIGNEXTENDARRAY ***************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * sign extend the given array of data, each entry of the given number of bits in size
 *
 * Inputs
 * ------
 *   ARRAY
 *   - the array of data values to sign extend
 *   SIZE
 *   - the number of entries/data points in the array
 *   BITS
 *   - the size of each data item in bits (including sign bit)
 * Outputs
 * -------
 *   ARRAY
 *   - the array of sign extended data items
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
#define SIGNEXTENDARRAY( ARRAY, SIZE, BITS ) { \
	unsigned int counter ; \
	for( counter = 0 ; counter < SIZE ; counter += 1 ) { \
		SIGNEXTEND( ARRAY[ counter ], BITS ) ; \
	} \
}

/**** TOTALBITS *********************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * determine the minimum number of bits that are required to hold the given array of
 * data
 *
 * Inputs
 * ------
 *   ARRAY
 *   - the array of data to determine the number of bits required
 *   SIZE
 *   - the number of entries/data points in the array
 *   BITS
 *   - integer to hold the minimum number of bits required for the data
 * Outputs
 * -------
 *   BITS
 *   - the minimum number of bits that are required to hold data
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
#define TOTALBITS( ARRAY, SIZE, BITS ) { \
	int	counter ; \
	int	maxBit ; \
	for( BITS = 0, counter = 0 ; counter < SIZE ; counter += 1, BITS += maxBit + 2 ) { \
	/* add 2 since data requires maxBit + 2 bits (1 for sign, 1 to shift 0..30 to 1..31) */ \
		MAXBITSET( ARRAY[ counter ], maxBit ) ; \
	} \
}

/**** TOTALBITS2D *******************************************************************
 *
 * Version & Date
 * -------   ----
 * 1.0.0, 30/06/1998
 *
 * Description
 * -----------
 * determine the minimum number of bits that are required to hold the given 2D array of
 * data
 *
 * Inputs
 * ------
 *   ARRAY
 *   - the array of data to determine the number of bits required
 *   WIDTH
 *   - the number of columns in the array
 *   HEIGHT
 *   - the number of rows in the array
 *   BITS
 *   - integer to hold the minimum number of bits required for the data
 * Outputs
 * -------
 *   BITS
 *   - the minimum number of bits that are required to hold data
 *
 * History (with dates)
 * -------  ---- -----
 * 1.0.0, 30/06/1998    first release
 *
 ************************************************************************************/
#define TOTALBITS2D( ARRAY, WIDTH, HEIGHT, BITS ) { \
	int y ; \
	int	bits1d ; \
	for( BITS = 0, y = 0 ; y < HEIGHT ; y += 1, BITS += bits1d ) { \
		TOTALBITS( ARRAY[ y ], WIDTH, bits1d ) ; \
	} \
}

void *SwitchEndian( void *data, unsigned int n, unsigned int bytes, unsigned int overwrite ) ;


#endif	/* _BITUTIL_C_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -