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:[EMAIL PROTECTED] Sent: Friday, July 18, 2003 9:04 AM To: 'li' Cc: linuxppc-embedded at 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/