It is currently Mon Oct 14, 2019 11:56 pm

 All times are UTC

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: MULU overflowPosted: Wed Oct 26, 2011 9:05 pm

Joined: Wed Oct 26, 2011 4:25 pm
Posts: 1
Location: Tampa, FL
Hi, I have some simple code:

Code:
*-----------------------------------------------------------
* Program : Code Test
*-------------------------------------------------------
START   ORG   \$1000
MOVE.L   #\$FFF,D5
MOVE.L   #2,D6
RPT   MULU   D6,D5
CMP   #\$FFFFFFFF,D5
BNE   RPT

STOP   #\$2700

END   START

But, when you try to max out D5 to FFFFFFFF,
it will not work.
Why?
MULU should give a 32-bit result.
Thanks for your help.
Code:

_________________
J. Israel

Top

 Post subject: Posted: Thu Oct 27, 2011 10:09 am

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
MULU has only word sized operands so ..

Code:
MULU    d6,d5

.. multiplies the word in d5 by the word in d6 and puts the longword result in d5. If d6 and d5 both held the largest unsigned word value of \$FFFF the result in d5 after the MULU would be \$FFFE0001.

Top

 Post subject: Posted: Thu Oct 27, 2011 3:20 pm

Joined: Mon Jul 26, 2010 11:43 pm
Posts: 198
Location: Aurora, IL
Even if it were to support 32-bit multiplications instead of 16 by 16 into 32, you're ability to detect an overflow in this manner is flawed.

Specifically, what are the odds for all numbers that the result will be exactly 0xFFFFFFFF?

I'm pretty sure it's zero here because no two possible 16-bit source values can get that result. The 68K does not clamp results, nor signals invalid values in the source register, nor overflows. You need to confirm both source registers do not exceed 0xFFFF.

Top

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

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 6 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
Powered by phpBB® Forum Software © phpBB Group