/*------------------------------------------------------------------------------ * Program : Subroutine for that multiplies two 8-bit signed integers using HW multiplier * Input : The input parameters are: R12 -- array starting address R13 -- the number of elements (assume it is =>1) R14 -- dispay (0 for P1&P2 and 1 for P3&P4) * Output : No output parameters *------------------------------------------------------------------------------*/ #include "msp430.h" ; #define controlled include file PUBLIC swmult RSEG CODE swmult: ; save the registers on the stack PUSH R7 ; temporal sum CLR R7 snext: ADD @R12+, R7 DEC R13 JNZ snext BIT #1, R14 ; display on P1&P2 JNZ sp34 ; it's P3&P4 MOV.B R7, P1OUT SWPB R7 MOV.B R7, P2OUT JMP send sp34: MOV.B R7, P3OUT SWPB R7 MOV.B R7, P4OUT send: POP R7 ; restore R7 RET END Total := 0 Repeat C := Op2 Mod 2 Op2 := Op2 Div 2 If C = 1 Then Total := Total + Op1 Op1 := Op1 * 2 Until Op2 = 0 use RRA, lsb goes into C