EASy68K  
It is currently Fri Dec 15, 2017 2:40 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Nov 08, 2016 9:38 pm 
Offline

Joined: Tue Nov 08, 2016 9:28 pm
Posts: 1
I have a question regarding the MULU instruction, its something of a weird behavior after doing it on a certain value. Suppose I have 000FFFFF in a data register. Now what I want to do is add another F so that the value is 00FFFFFF. What I do is I first multiply the current value by 16, and and 'F' like so:

Code:
MULU   #16, d4
ADD.B  #$F, d4


The problem is that in the state of 000FFFFF, when I go to perform that operation again, I don't get another F, instead I get 000FFFF0. Another thing I've noticed is that if I just add 1 to 000FFFFF, the Extend, Zero, and bits are 1. What can I do remedy this issue?

If instead of multiplying by 16, I multiply by 17, I get that new bit (00XXXXXX).


Top
 Profile  
 
PostPosted: Wed Nov 09, 2016 11:35 am 
Offline
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1056
MULU multiplies two 16bit unsigned numbers yielding a 32bit result. $0000FFFF x $00000010 = $000FFFF0.
Note the first number is $0000FFFF not $000FFFFF. The upper word of the value is ignored because it is beyond
the 16bit range of the instruction.

Use the LSL.L instruction to shift in bits.

_________________
Prof. Kelly


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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