8x8 Unsigned Multiply Routine shows the instruction sequence for an 8x8 unsigned multiplication. Only one instruction is required when one of the arguments is already loaded in the WREG register. 8x8 Signed Multiply Routine shows the sequence to do an 8x8 signed multiplication. To account for the sign bits of the arguments, each argument’s Most Significant bit (MSb) is tested and the appropriate subtractions are done.
MOVF ARG1, W ;
MULWF ARG2 ; ARG1 * ARG2 -> PRODH:PRODL
MOVF ARG1, W
MULWF ARG2 ; ARG1 * ARG2 -> PRODH:PRODL
BTFSC ARG2, SB ; Test Sign Bit
SUBWF PRODH, F ; PRODH = PRODH - ARG1
MOVF ARG2, W
BTFSC ARG1, SB ; Test Sign Bit
SUBWF PRODH, F ; PRODH = PRODH - ARG2