Ross Myers

Swapping bytes & ASR/ASL

Discussion created by Ross Myers on Jul 14, 2009
Latest reply on Jul 16, 2009 by Ross Myers

Hi All,


On a Coldfire V1 I want to swap the bytes in a word, eg.





I came up with this convoluted method, is there a simpler way?


Enter with value to swap in d0

 moveq        #0,d1
 lsl.l        #8,d0
 add.l        d0,d1
 andi.l       #$FFFF,d0
 lsr.l        #8,d1
 lsr.l        #8,d1
 add.l        d1,d0


One final question, with the ROR & ROL Opcodes gone in the CFV1 Core, is the best option to use ASR,ASL instead and monitor the CCR(C)?




Message Edited by Bloodhound on 2009-07-14 04:57 PM