It is currently Fri May 29, 2020 2:53 am

 All times are UTC

 Page 1 of 1 [ 11 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: easy instructionsPosted: Sat Dec 15, 2012 12:49 pm

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

 Post subject: Re: easy instructionsPosted: Sat Dec 15, 2012 1:01 pm

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

 Post subject: Re: easy instructionsPosted: Sat Dec 15, 2012 1:20 pm

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

 Post subject: Re: easy instructionsPosted: Sat Dec 15, 2012 1:50 pm

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

 Post subject: Re: easy instructionsPosted: Sat Dec 15, 2012 2:02 pm

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

Top

 Post subject: Re: easy instructionsPosted: Sat Dec 15, 2012 2:39 pm

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

 Post subject: Re: easy instructionsPosted: Sat Dec 15, 2012 4:43 pm

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

 Post subject: Re: easy instructionsPosted: Sat Dec 15, 2012 5:04 pm

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

 Post subject: Re: easy instructionsPosted: Sat Dec 15, 2012 5:17 pm

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

 Post subject: Re: easy instructionsPosted: Sat Dec 15, 2012 6:16 pm

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

 Post subject: Re: easy instructionsPosted: Sat Dec 15, 2012 6:20 pm

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

Top

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

 All times are UTC

#### Who is online

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