Re: at2 swap_nibbles

Andreas Fink <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
On Montag, November 25, 2002, at 06:54  Uhr, Oded Arbel wrote:

>  
> Yes. will somebody just shoot me where I stand ? will save me lots of 
> trouble ;-)
> I shoud have said
> return ( ( byte &  0x0F )  << 4 )  |  (  ( byte  & 0xF0 ) >> 4 ); 
> I'll fix ?
>  

how about this:

#define	HI_NIBBLE(a)	( (int)a >> 4 & 0x0F)
#define	LOW_NIBBLE(a)	( (int)a & 0x0F)
#define	SWAP_NIBBLE(a)	(( HI_NIBBLE(a) | (LOW_NIBBLE(a) << 4)) & 0xFF)

This would work as a macro and has the advantage that the CPU can run 
it pretty much native.


Andreas Fink
Fink Consulting GmbH

---------------------------------------------------------------
Tel: +41-61-6666332 Fax: +41-61-6666331  Mobile: +41-79-2457333
Address: Clarastrasse 3, 4058 Basel, Switzerland
E-Mail:  [email protected]
Homepage: http://www.finkconsulting.com
---------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.