EASy68K  
It is currently Mon Sep 23, 2019 5:54 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Decomposing a word
PostPosted: Fri Dec 16, 2011 8:00 pm 
Offline

Joined: Fri Dec 16, 2011 12:32 am
Posts: 17
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.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 17, 2011 5:01 am 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
I'd just shuffle them around, which is reasonably efficient

Code:
   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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 17, 2011 11:27 am 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
You could replace both the CLR and the SWAP with a MOVEQ #0,d1

Lee.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2012 1:43 pm 
Offline

Joined: Fri Dec 16, 2011 12:32 am
Posts: 17
clive wrote:
I'd just shuffle them around, which is reasonably efficient

Code:
   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


Thank you, very elegant solution. I appreciate it!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2012 1:44 pm 
Offline

Joined: Fri Dec 16, 2011 12:32 am
Posts: 17
lee wrote:
You could replace both the CLR and the SWAP with a MOVEQ #0,d1

Lee.


Yes, I like this method better. Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2012 1:11 am 
Offline

Joined: Wed Feb 22, 2012 2:17 am
Posts: 8
Location: toronto
assemlbey_dude wrote:
lee wrote:
You could replace both the CLR and the SWAP with a MOVEQ #0,d1

Lee.


there is no need for the swap just clr.l d1


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 23, 2012 4:45 pm 
Offline

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
etw3 wrote:
there is no need for the swap just clr.l d1


Which 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,D0


AND.W #$FFFF,D0 wouldn't work because it sign extends.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group