|
Notice that:
|
|
Therefore:
|
|
MULS <ea>, Dn Multiply the 16 bit integer value in the operand specified by <ea> to the 16 bit value in data register Dn The product is always 32 bits and it is stored in data register Dn In other words: Dn(16 bits) × <ea>(16 bits) ⇒ Dn(32 bits) |
|
+----------+----------+----------+----------+ D0 = | 10101010 | 01010101 | 00000000 | 00001001 | +----------+----------+----------+----------+ The 16 bit operand in D0 is equal to: (00000000 00001001)(2) = 1 + 8 = 9(10) |
The 16 bit representation in register D0 represents the decimal value 9(10)
Suppose we execute the following multiply instruction:
MULS #3, D0 |
The data register D0 will contain the following result after the instruction is executed:
+----------+----------+----------+----------+ D0 = | 00000000 | 00000000 | 00000000 | 00011011 | +----------+----------+----------+----------+ The 32 bit result in D0 is equal to: (00000000 00000000 00000000 00011011)(2) = 1 + 2 + 8 + 16 = 27(10) |
Notice that all 32 bits in the register D0 are updated because the product of two 16-bit binary number is always 32 bits.
|
DIVS <ea>, Dn Divides a 32 bit value in data register Dn by a 16-bit value specified by <ea> In other words: Dn(32 bits) / <ea>(16 bits) Result: (1) the quotient is stored in the lower 16 bits of data register Dn (2) the remainder is stored in the upper 16 bits of data register Dn |
|
+----------+----------+----------+----------+ D0 = | 00000000 | 00000000 | 00000000 | 00001001 | +----------+----------+----------+----------+ The 32 bits represents the value 9(10) |
Then after executing the following DIVS instruction:
DIVS #4, D0 9 / 4 --> Quotient = 2 Remainder = 1 |
The data register D0 will contain:
+----------+----------+----------+----------+ D0 = | 00000000 | 00000001 | 00000000 | 00000010 | +----------+----------+----------+----------+ |
|
|
|
|
|
|