|
Syntax: |
Operation: |
Operands: |
Program Counter: |
Opcode |
Comment |
Stack |
|
MULSU Rd,Rr |
R1:R0 = Rd × Rr (signed = signed × unsigned) |
16 <= d <= 23, 16 <= r <= 23 |
PC = PC + 1 |
000000110ddd0rrr |
This instruction performs 8-bit × 8-bit -> 16-bit multiplication of a signed and an unsigned number.
Rd
Rr
R1
R0
->
|
Product High |
Product Low |
Multiplicand
Multiplier
8
8
16
The multiplicand Rd and the multiplier Rr are two registers. The multiplicand Rd is a signed number, and the multiplier Rr is unsigned. The 16-bit signed product is placed in R1 (high byte) and R0 (low byte).
This instruction is not available on all devices. Refer to Appendix A.
|
I |
– |
||
|
T |
– |
||
|
H |
– |
||
|
S |
– |
||
|
V |
– |
||
|
N |
– |
||
|
Z |
⇔ |
~R15 AND ~R14 AND ~R13 AND ~R12 AND ~R11 AND ~R10 AND ~R9 AND ~R8 ANDR7 AND ~R6 AND ~R5 AND ~R4 AND ~R3 AND ~R2 AND ~R1 AND ~R0 |
Set if the result is 0x0000; cleared otherwise. |
|
C |
⇔ |
R15 |
|
|
R (Result) |
R (Result) equals R1,R0 after the operation. |
;******************************************************************************
;* DESCRIPTION
;* Signed multiply of two 16-bit numbers with 32-bit result.
;* USAGE
;* r19:r18:r17:r16 = r23:r22 * r21:r20
;******************************************************************************
muls16x16_32:
clr r2
muls r23, r21 ; (signed)ah * (signed)bh
movw r18, r0
mul r22, r20 ; al * bl
movw r16, r0
mulsu r23, r20 ; (signed)ah * bl
sbc r19, r2
add r17, r0
adc r18, r1
adc r19, r2
mulsu r21, r22 ; (signed)bh * al
sbc r19, r2
add r17, r0
adc r18, r1
adc r19, r2
ret
1 (2 bytes)
|
Name |
Cycles |
|
AVRe |
2 |
|
AVRxm |
2 |
|
AVRxt |
2 |
|
AVRrc |
N/A |