need a fast byteorder changing routine

Wells, Charles Charles.Wells at nielsenmedia.com
Fri Jul 18 23:03:35 EST 2003


Li,

There's several ways of doing it.  This way is pretty fast and makes few
assumptions about the buffer.

void FixEndian(long* buf, unsigned long num_longs)
{
  __asm__(" addi   3,3,-4");
  __asm__(" mtspr  9,4");
  __asm__(" lwzu   4,4(3)");
  __asm__(" stwbrx 4,0,3");
  __asm__(" bc     16,0,$-8");
}

Charlie

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-embedded mailing list