Thread (2 messages) 2 messages, 2 authors, 2003-07-18

Re: need a fast byteorder changing routine

From: Peter Barada <hidden>
Date: 2003-07-18 14:35:58

Li,

If you must do it one word at a time, the following works.

long SwapBytes(long* p)
{
 __asm__(" lwbrx 3,0,3");
}

Charlie
And if you want it inlined:

static inline unsigned long loadWordAndSwapBytes(unsigned long *p)
{
  unsigned long val;

  __asm__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (p));
  return val;
}

--
Peter Barada                             Peter.Barada@motorola.com
Wizard                                   781-852-2768 (direct)
WaveMark Solutions(A Motorola Company)   781-270-0193 (fax)

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help