#Swapping Bytes…
3 messages in this thread
To anyone with 68000 assembler experience: What is the quickest way to
swap the bytes in the low-order word of a register? For example, if D0
contains $xxyy, what is the quickest way to change it to $yyxx? Along the
same lines, what is the quickest way to convert D0=$wwxxyyzz to
D0=$zzyyxxww?
I don't use 68000 assembly, but looking at the Motorola book, it seems
you're looking for the SWAP command which swaps the 2 16bit halves of a
register:
SWAP d0
For the 2nd, where you move the 8 high bits into the 8 low bits
then it would appear an ROL command would work:
ROL #8,d0
You might check them in your manual, they may or may not be what
you're looking for.
Dave,
If I remember correctly, (and I'll be corrected if I'm wrong), the
sequence you can use is this.
SWAP.B D0
SWAP.W D0
SWAP.B D0
The .B swaps the bytes in the low word and the .W swaps the upper and
lower word. I don't have my bools right here, but I think that the entire
operation can be done in 12-24 clocks.