EASy68K  
It is currently Thu Apr 02, 2020 12:35 pm

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Mon Oct 29, 2012 5:44 pm 
Offline

Joined: Mon Oct 29, 2012 4:50 pm
Posts: 5
What are the few lines of code that would switch D0 from being ABCD1234 into 4321DCBA?

Thanks all!

:roll:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2012 7:23 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
Swap the nibbles of the byte.
Swap the bytes of the word.
Swap the nibbles of the byte.
Swap the words.
Repeat the first three steps.
Done.

Lee.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2012 9:07 pm 
Offline

Joined: Mon Oct 29, 2012 4:50 pm
Posts: 5
I don't understand your answer.
Can you or someone else post the few lines of code that would get this done?

I learn by example, not by guidance.


Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2012 9:22 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
A register can hold a longword, word or byte value. A longword value is held in all 32 bits, a word value is held in the lower sixteen bits, bits 0 to 15, and a byte value in the lowest eight bits, bits 0 to 7.

If you specify an opcode size as .b only the byte value, bits 0 to 7, will be affected.

If you specify an opcode size as .w only the word value, bits 0 to 15, will be affected.

If you specify an opcode size as .l all 32 bits, from 0 to 31, will be affected.

Quote:
I learn by example, not by guidance.

Shame, I can learn from both.

Lee.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2012 11:07 pm 
Offline

Joined: Mon Oct 29, 2012 4:50 pm
Posts: 5
If you cannot figure out the code, that's cool.

Can someone else assist?

Thanks in advance...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 29, 2012 11:19 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
Quote:
If you cannot figure out the code, that's cool.

Waaaahahahahahahahaha.

Nope, still not giving you the answer.

Quote:
Can someone else assist?

Unlikely to happen here, giving answers is frowned upon.

Why not have a stab at it yourself? The solution is in my first reply.

Or explain a bit more what it is you don't understand in my answer.

Lee.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 30, 2012 1:32 pm 
Offline

Joined: Mon Oct 29, 2012 4:50 pm
Posts: 5
A little weird that answers to simple specifics are frowned upon, but when in Rome I guess...

Here's what I have, but the ASL and the ROXR are giving errors.
It's the first time I have tried to use them and I can't understand the manual.

Either way, I am getting an error.

ORG $1000

START MOVE.B #32,D0
CLR.L D1

LOOP ASL.L D0
ROXR.L D1
SUBI.B #1,D0
BNE LOOP

MOVE.B #9,D0
TRAP #15

END START


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 30, 2012 4:59 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
Quote:
A little weird that answers to simple specifics are frowned upon

That's because simple questions are often lab or homework questions. Answering these questions directly does not help the student, so this is not done.

Now to your code ..

When the destination of an ASd is an address the bit shift count is fixed at one bit. However when destination of an ASd is a register a count of the number of bit positions to shift is required before the affected register. From the programmer's manual the legal formats are ..

Code:
 ASd   Dx,Dy         * shift Dy by Dx number of bits
 ASd   #<data>,Dy    * shift Dy by <data> number of bits
 ASd   <ea>          * shift <ea> by one bit

 where d is the direction, L or R

It looks from your code as though you're trying to reverse the order of all 32 bits but from your first question it looks like you are trying to reverse the order of the eight nibbles - groups of four bits. Which is it?

Lee.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 31, 2012 12:55 pm 
Offline

Joined: Mon Oct 29, 2012 4:50 pm
Posts: 5
I figured it out, 32 bits so 2 longwords.
I just needed to add the #1, before D0 and D1


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 31, 2012 4:54 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1118
Thanks Lee. Well done, as always.

_________________
Prof. Kelly


Top
 Profile  
 
PostPosted: Sat Nov 24, 2012 11:32 pm 
Offline

Joined: Fri Dec 19, 2008 1:12 pm
Posts: 37
A bit late, but here's another solution:

Code:
    rol.w   #8,d0
    swap    d0
    rol.w   #8,d0
    move.l  d0,d1
    and.l   #$f0f0f0f0,d0
    eor.l   d0,d1
    lsr.l   #4,d0
    lsl.l   #4,d1
    or.l    d1,d0

Register d0 is the input and the output.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 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