--- In lpc2000@yahoogroups.com, "James Dabbs" <jdabbs@t...> wrote: > Is there a clever, quick way to do 16-bit and 32-bit byte swaps in ARM > with only one or two instructions? > > Thanks, > > James Dabbs For such nuggets I really suggest the ARM System Developer's Guide which has the following: @ r0 is source/dest @ r1,r2 are scratch mvn r2, #0x0000FF00 eor r1, r0, r0, ROR #16 and r1, r2,r1, LSR #8 eor r0, r1, r0, ROR #8 or eor r1,r0,r0,ROR #16 mov r1,r1, LSR#8 bic r1,r1,#0xFF00 EOR r0, r1, r0,ROR #8 To swap two 16-bits in a 32-bit mov r0,r0,ROR #16
Message
Re: Byte Swap Instruction
2005-04-09 by embeddedjanitor