public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
* RE: need a fast byteorder changing routine
@ 2003-07-18 13:03 Wells, Charles
  0 siblings, 0 replies; 4+ messages in thread
From: Wells, Charles @ 2003-07-18 13:03 UTC (permalink / raw)
  To: 'li'; +Cc: linuxppc-embedded


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/

^ permalink raw reply	[flat|nested] 4+ messages in thread
* RE: need a fast byteorder changing routine
@ 2003-07-18 13:24 Wells, Charles
  2003-07-18 14:35 ` Peter Barada
  0 siblings, 1 reply; 4+ messages in thread
From: Wells, Charles @ 2003-07-18 13:24 UTC (permalink / raw)
  To: 'li'; +Cc: linuxppc-embedded


Li,

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

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

Charlie

-----Original Message-----
From: Wells, Charles [mailto:Charles.Wells@nielsenmedia•com]
Sent: Friday, July 18, 2003 9:04 AM
To: 'li'
Cc: linuxppc-embedded@lists•linuxppc.org
Subject: RE: need a fast byteorder changing routine



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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-07-18 14:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Xx969281867387.18796@webmail1.inner-21cn.com>
2003-07-18  6:26 ` need a fast byteorder changing routine Wojciech Kromer
2003-07-18 13:03 Wells, Charles
  -- strict thread matches above, loose matches on Subject: below --
2003-07-18 13:24 Wells, Charles
2003-07-18 14:35 ` Peter Barada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox