EASy68K  
It is currently Sat Nov 16, 2019 10:27 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: MULU overflow
PostPosted: Wed Oct 26, 2011 9:05 pm 
Offline

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
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2011 10:09 am 
Offline

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
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2011 3:20 pm 
Offline

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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 6 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