Search code examples
assemblymultiplicationinstruction-set68000

68000 Assembly: Multiplying gives a weird result


I have a question regarding the MULU instruction. One thing I've noticed is that suppose I have the value 000FFFFF in a data register. And then suppose I want to put in another F so that it contains 00FFFFFF. What I usually do is multiply the data register by 16 like so:

MULU  #16, D4

And then I add another F by doing ADD instruction (so I get 00FFFFFF). But when I multiplied again on 000FFFFF, all the bits inside the data register end up going to zero (00000000). After that multiply, I will have 000FFFF0, and then the rest will follow. I still don't understand the reason for this. I looked up this example and I feel that it should work. I also noticed that the Extend, Carry, and Zero bits all go to true if I simply add 1 to 000FFFFF


Solution

  • Do not use multiplication. Instead, use LSL.L #4, (register) and that will yield the result needed in a much better way.