Texas Instruments MSP430x1xx Computer Hardware User Manual


 
Hardware Multiplier Operation
7-5
Hardware Multiplier
7.2.3 Software Examples
Examples for all multiplier modes follow. All 8x8 modes use the absolute
address for the registers because the assembler will not allow .B access to
word registers when using the labels from the standard definitions file.
; 16x16 Unsigned Multiply
MOV #01234h,&MPY ; Load first operand
MOV #05678h,&OP2 ; Load second operand
; ... ; Process results
; 8x8 Unsigned Multiply. Absolute addressing.
MOV.B #012h,&0130h ; Load first operand
MOV.B #034h,&0138h ; Load 2nd operand
; ... ; Process results
; 16x16 Signed Multiply
MOV #01234h,&MPYS ; Load first operand
MOV #05678h,&OP2 ; Load 2nd operand
; ... ; Process results
; 8x8 Signed Multiply. Absolute addressing.
MOV.B #012h,&0132h ; Load first operand
SXT &MPYS ; Sign extend first operand
MOV.B #034h,&0138h ; Load 2nd operand
SXT &OP2 ; Sign extend 2nd operand
; (triggers 2nd multiplication)
; ... ; Process results
; 16x16 Unsigned Multiply Accumulate
MOV #01234h,&MAC ; Load first operand
MOV #05678h,&OP2 ; Load 2nd operand
; ... ; Process results
; 8x8 Unsigned Multiply Accumulate. Absolute addressing
MOV.B #012h,&0134h ; Load first operand
MOV.B #034h,&0138h ; Load 2nd operand
; ... ; Process results
; 16x16 Signed Multiply Accumulate
MOV #01234h,&MACS ; Load first operand
MOV #05678h,&OP2 ; Load 2nd operand
; ... ; Process results
; 8x8 Signed Multiply Accumulate. Absolute addressing
MOV.B #012h,&0136h ; Load first operand
SXT &MACS ; Sign extend first operand
MOV.B #034h,R5 ; Temp. location for 2nd operand
SXT R5 ; Sign extend 2nd operand
MOV R5,&OP2 ; Load 2nd operand
; ... ; Process results