need a fast byteorder changing routine

Peter Barada pbarada at mail.wm.sps.mot.com
Sat Jul 19 00:35:58 EST 2003


>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 at 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/





More information about the Linuxppc-embedded mailing list