Section 04 Part 08 – The MULU & MULS Instructions


But I was thinking of a way To multiply by ten, And always, in the answer, get The question back again.” ~Lewis Carroll






These two instructions are for multiplication, and there are two of them because one is for unsigned and the other is for signed.




The MULU Instruction


MULU – Unsigned MULtiply


This instruction will multiply a word of the destination operand by the word of the source operand; the result is saved in long-word in the destination operand.






This is pretty much simple multiplication right here.  So, we’ll start with this:


          mulu.w    #$0010,d0


We’ll pretend that d0 contains 00200040 for this example.


What happens is the word of d0 is read (0040) and is multiplied by 0010.


0040 x 0010 = 00000400


The result is then saved into d0, and now d0 contains 00000400.  You’ll notice the 0020 that was in the upper word of d0 was replaced and ignored entirely, be sure to keep that in mind.


We’ll have another example, this time d0 contains FFFFF800:


          mulu.w    #$0087,d0


The word of d0 (F800) is multiplied by 0087.


F800 x 0087 = 0082C800


The result is then saved into d0, and now d0 contains 0082C800.  Remember, MULU is unsigned multiplication, so both F800 and 0087 are treated as unsigned numbers (positive).


The destination operand must be a data register; the source operand however, can be an immediate number, a data register, a memory address, or even a memory address using an address register.  A few examples:


          mulu.w    d1,d0

          mulu.w    $00000010,d0

          mulu.w    (a0),d0


In all of these examples above, the word of the d0, is multiplied by a word of the source operands.  And the result is always a long-word saved back into d0.


The only thing you cannot use for the source operand is an address register directly:


          mulu.w    a0,d0


And one final note, the size can only be word, you cannot use byte or long-word. 




The MULS Instruction


MULS – Signed MULtiply


This is exactly the same as the MULU instruction (including syntax rules).  Except of course, the source and destination are both treated as “signed” instead of “unsigned”.  So numbers that are from 8000 to FFFF are negative.






We’ll pretend that d0 contains 0000FFC0 in this example.


          muls.w    #$0010,d0


So, the word FFC0 from d0 is multiplied by the word 0010.


FFC0 x 0010 = FFFFFC00


Notice how the FFC0 is treated a negative, while 0010 is positive.  What you effectively have is:


-0040 x +0010 = -00000400


And so, d0 now contains FFFFFC00 (-400).


That is the only difference between MULU and MULS.




Previous Part

Main Page

Next Part