32-Bit Hardware Multiplier Operation
9-16
32-Bit Hardware Multiplier
Given the separation in processing of 16-bit operations (32-bit results) and
32-bit operations (64-bit results) by the module, it is important to understand
the implications when using MAC/MACS operations and mixing 16-bit
operands/results with 32-bit operands/results. User software must address
these points during usage when mixing these operations. The following code
illustrates the issue.
; Mixing 32x24 multiplication with 16x16 MACS operation
MOV
#MPYSAT,&MPY32CTL0; Saturation mode
MOV
#052C5h,&MPY32L ; Load low word of 1st operand
MOV
#06153h,&MPY32H ; Load high word of 1st operand
MOV
#001ABh,&OP2L
; Load low word of 2nd operand
MOV.B #023h,&OP2H_B
; Load high word of 2nd operand
;... 5 NOPs required
MOV
&RES0,R6
; R6 = 00E97h
MOV
&RES1,R7
; R7 = 0A6EAh
MOV
&RES2,R8
; R8 = 04F06h
MOV
&RES3,R9
; R9 = 0000Dh
; Note that MPYC = 0!
MOV
#0CCC3h,&MACS
; Signed MAC operation
MOV
#0FFB6h,&OP2
; 16x16 bit operation
MOV
&RESLO,R6
; R6 = 0FFFFh
MOV
&RESHI,R7
; R7 = 07FFFh
The second operation gives a saturated result because the 32-bit value used
for the 16x16 bit MACS operation was already saturated when the operation
was started: the carry bit MPYC was 0 from the previous operation but the most
significant bit in result register RES1 is set. As one can see in the flow chart
the content of the result registers are saturated for multiply-and-accumulate
operations after starting a new operation based on the previous results but
depending on the size of the result (32-bit or 64-bit) of the newly initiated
operation.
The saturation before the multiplication can cause issues if the MPYC bit is not
properly set as the following code example illustrates.
;Pre−load result registers to demonstrate overflow
MOV
#0,&RES3
;
MOV
#0,&RES2
;
MOV
#0,&RES1
;
MOV
#0,&RES0
;
; Saturation mode and set MPYC:
MOV
#MPYC,&MPY32CTL0
MOV.B #082h,&MACS_B
; 8-bit signed MAC operation
MOV.B #04Fh,&OP2_B
; Start 16x16 bit operation
MOV
&RES0,R6
; R6 = 00000h
MOV
&RES1,R7
; R7 = 08000h
Содержание MSP430x4xx Family
Страница 1: ...MSP430x4xx Family 2007 Mixed Signal Products User s Guide SLAU056G ...
Страница 2: ......
Страница 6: ...vi ...
Страница 114: ...3 76 RISC 16 Bit CPU ...
Страница 304: ...5 20 FLL Clock Module ...
Страница 340: ...7 8 Supply Voltage Supervisor ...
Страница 348: ...8 8 16 Bit Hardware Multiplier ...
Страница 372: ...9 24 32 Bit Hardware Multiplier ...
Страница 400: ...10 28 DMA Controller ...
Страница 428: ...13 10 Basic Timer1 ...
Страница 466: ...15 24 Timer_A ...
Страница 522: ...17 30 USART Peripheral Interface UART Mode ...
Страница 544: ...18 22 USART Peripheral Interface SPI Mode ...
Страница 672: ...23 12 Comparator_A ...
Страница 692: ...24 20 LCD Controller ...
Страница 746: ...26 28 ADC12 ...