EASy68Khttp://www.easy68k.com/EASy68Kforum/ Decomposing a wordhttp://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1069 Page 1 of 1

 Author: assemlbey_dude [ Fri Dec 16, 2011 8:00 pm ] Post subject: Decomposing a word Hello everyone. What would be the easiest way to "decompose" a word. For example \$85F2 into \$08050F02. I am new to the EASY68k simulator and assembler. I understand how to use ROL, ROR, LSL,LSR. I also understand the concept of masking bits.

 Author: clive [ Sat Dec 17, 2011 5:01 am ] Post subject: I'd just shuffle them around, which is reasonably efficientCode:   MOVE.W   #\$85F2,D0      CLR.W   D1   SWAP   D1   MOVE.W   D0,D1   LSL.L   #4,D1   LSR.W   #4,D1   LSL.L   #8,D1   LSR.W   #4,D1   LSR.B   #4,D1

 Author: lee [ Sat Dec 17, 2011 11:27 am ] Post subject: You could replace both the CLR and the SWAP with a MOVEQ #0,d1Lee.

 Author: assemlbey_dude [ Tue Jan 03, 2012 1:43 pm ] Post subject: clive wrote:I'd just shuffle them around, which is reasonably efficientCode:   MOVE.W   #\$85F2,D0      CLR.W   D1   SWAP   D1   MOVE.W   D0,D1   LSL.L   #4,D1   LSR.W   #4,D1   LSL.L   #8,D1   LSR.W   #4,D1   LSR.B   #4,D1Thank you, very elegant solution. I appreciate it!

 Author: assemlbey_dude [ Tue Jan 03, 2012 1:44 pm ] Post subject: lee wrote:You could replace both the CLR and the SWAP with a MOVEQ #0,d1Lee.Yes, I like this method better. Thank you.

 Author: etw3 [ Thu Feb 23, 2012 1:11 am ] Post subject: assemlbey_dude wrote:lee wrote:You could replace both the CLR and the SWAP with a MOVEQ #0,d1Lee.there is no need for the swap just clr.l d1

 Author: clive [ Thu Feb 23, 2012 4:45 pm ] Post subject: etw3 wrote:there is no need for the swap just clr.l d1Which I guess was Lee's point, except that MOVEQ is 4 cycles, and CLR.L is 8 cycles.I basically demonstrated a way of doing it, which expressed the need to clear the high order word for the subsequent code to work, in retrospect I could have trimmed the coding some more, but had probably been thinking about doing it in a single register.Code:   MOVE.W   #\$85F2,D0   AND.L   #\$FFFF,D0      LSL.L   #4,D0   LSR.W   #4,D0   LSL.L   #8,D0   LSR.W   #4,D0   LSR.B   #4,D0AND.W #\$FFFF,D0 wouldn't work because it sign extends.