MPY32 Operation
276
SLAU367P – October 2012 – Revised April 2020
Copyright © 2012–2020, Texas Instruments Incorporated
32-Bit Hardware Multiplier (MPY32)
5.2.2.1
MACS Underflow and Overflow
The multiplier does not automatically detect underflow or overflow in MACS mode. For example, working
with 16-bit input data and 32-bit results (that is, using only RESLO and RESHI), the available range for
positive numbers is 0 to 07FFF FFFFh and for negative numbers is 0FFFF FFFFh to 08000 0000h. An
underflow occurs when the sum of two negative numbers yields a result that is in the range for a positive
number. An overflow occurs when the sum of two positive numbers yields a result that is in the range for a
negative number.
The SUMEXT register contains the sign of the result in both cases described above, 0FFFFh for a 32-bit
overflow and 0000h for a 32-bit underflow. The MPYC bit in MPY32CTL0 can be used to detect the
overflow condition. If the carry is different from the sign reflected by the SUMEXT register, an overflow or
underflow occurred. User software must handle these conditions appropriately.
5.2.3 Software Examples
Examples for all multiplier modes follow. All 8×8 modes use the absolute address for the registers,
because the assembler does not allow .B access to word registers when using the labels from the
standard definitions file.
There is no sign extension necessary in software. Accessing the multiplier with a byte instruction during a
signed operation automatically causes a sign extension of the byte within the multiplier module.
; 32x32 Unsigned Multiply
MOV
#01234h,&MPY32L
; Load low
word of 1st operand
MOV
#01234h,&MPY32H
; Load high word of 1st operand
MOV
#05678h,&OP2L
; Load low
word of 2nd operand
MOV
#05678h,&OP2H
; Load high word of 2nd operand
;
...
; Process results
; 16x16 Unsigned Multiply
MOV
#01234h,&MPY
; Load 1st operand
MOV
#05678h,&OP2
; Load 2nd operand
;
...
; Process results
; 8x8 Unsigned Multiply. Absolute addressing.
MOV.B
#012h,&MPY_B
; Load 1st operand
MOV.B
#034h,&OP2_B
; Load 2nd operand
;
...
; Process results
; 32x32 Signed Multiply
MOV
#01234h,&MPYS32L
; Load low
word of 1st operand
MOV
#01234h,&MPYS32H
; Load high word of 1st operand
MOV
#05678h,&OP2L
; Load low
word of 2nd operand
MOV
#05678h,&OP2H
; Load high word of 2nd operand
;
...
; Process results
; 16x16 Signed Multiply
MOV
#01234h,&MPYS
; Load 1st operand
MOV
#05678h,&OP2
; Load 2nd operand
;
...
; Process results
; 8x8 Signed Multiply. Absolute addressing.
MOV.B
#012h,&MPYS_B
; Load 1st operand
MOV.B
#034h,&OP2_B
; Load 2nd operand
;
...
; Process results