It is currently Sun Jan 26, 2020 1:06 pm

 All times are UTC

 Page 1 of 1 [ 7 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Decomposing a wordPosted: Fri Dec 16, 2011 8:00 pm

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

 Post subject: Posted: Sat Dec 17, 2011 5:01 am

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

 Post subject: Posted: Sat Dec 17, 2011 11:27 am

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

 Post subject: Posted: Tue Jan 03, 2012 1:43 pm

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

 Post subject: Posted: Tue Jan 03, 2012 1:44 pm

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

 Post subject: Posted: Thu Feb 23, 2012 1:11 am

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

 Post subject: Posted: Thu Feb 23, 2012 4:45 pm

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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 7 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Google [Bot] and 4 guests

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

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects