EASy68K  
It is currently Fri May 29, 2020 11:35 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: easy instructions
PostPosted: Sat Dec 15, 2012 12:49 pm 
Offline

Joined: Thu Nov 08, 2012 6:07 pm
Posts: 12
Move.B #59,D1
MOVE.B #18,D3

MOVE.B #10,D4
DIVU D4,D3
MULU D3,D1
Hi all, when I execute these instruction the value of D1 does not change after multiplication can anyone answer me why this happen?


Top
 Profile  
 
 Post subject: Re: easy instructions
PostPosted: Sat Dec 15, 2012 1:01 pm 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1122
The MULU instruction multiplies the 16 bit source times the 16 bit destination.

In your code example the lower 16 bits of D3 contains 1, so D1 does not change
because it is being multiplied by 1.

_________________
Prof. Kelly


Top
 Profile  
 
 Post subject: Re: easy instructions
PostPosted: Sat Dec 15, 2012 1:20 pm 
Offline

Joined: Thu Nov 08, 2012 6:07 pm
Posts: 12
thanks alot prof kelly, but I want to ask you how can I fix this problem


Top
 Profile  
 
 Post subject: Re: easy instructions
PostPosted: Sat Dec 15, 2012 1:50 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
What problem? The result you're getting is correct for integer maths.

If what you want is to calculate 18 / 10 * 59 what you should do is 59 * 18 / 10 instead. That way you will get more effective digits in your result.

Lee.


Top
 Profile  
 
 Post subject: Re: easy instructions
PostPosted: Sat Dec 15, 2012 2:02 pm 
Offline

Joined: Thu Nov 08, 2012 6:07 pm
Posts: 12
No , it is not the correct answer.


Top
 Profile  
 
 Post subject: Re: easy instructions
PostPosted: Sat Dec 15, 2012 2:39 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
The correct answer is 106 with a remainder of two, which is what you get if you do ..
Code:
      ORG   $1000

start
      MOVEQ       #59,D1
      MOVEQ       #18,D3
      MOVEQ       #10,D4

      MULU.w      D1,D3       * 59 x 18
      DIVU        D4,D3       * / 10

      NOP

      END   start
Lee.


Top
 Profile  
 
 Post subject: Re: easy instructions
PostPosted: Sat Dec 15, 2012 4:43 pm 
Offline

Joined: Thu Nov 08, 2012 6:07 pm
Posts: 12
OK , I knew that but I am wondering why the output is 131178? it must give me 106.2 right?


Top
 Profile  
 
 Post subject: Re: easy instructions
PostPosted: Sat Dec 15, 2012 5:04 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
Read the description for DIVU. What you are seeing is the result and the remainder as one longword.
Quote:
it must give me 106.2 right?
No, it will never give you 106.2, the 68000 can only do integer maths.

Lee.


Top
 Profile  
 
 Post subject: Re: easy instructions
PostPosted: Sat Dec 15, 2012 5:17 pm 
Offline

Joined: Thu Nov 08, 2012 6:07 pm
Posts: 12
mmmmmm, I am confused what actually am doing is to convert temperature from Celsius (°C) to Fahrenheit (°F) depends on relation
[°F] = [°C] × 9⁄5 + 32. the result is not true if the out put shown before.


Top
 Profile  
 
 Post subject: Re: easy instructions
PostPosted: Sat Dec 15, 2012 6:16 pm 
Offline

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
Go read about DIVU again and also learn carefully the difference between words and longwords.

Lee.


Top
 Profile  
 
 Post subject: Re: easy instructions
PostPosted: Sat Dec 15, 2012 6:20 pm 
Offline

Joined: Thu Nov 08, 2012 6:07 pm
Posts: 12
OK, thanks


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 7 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:  
Powered by phpBB® Forum Software © phpBB Group