# 16x16 Unsigned Multiplication Algorithm

16x16 Unsigned Multiply Routine shows the sequence to do a 16x16 unsigned multiplication. 16x16 Unsigned Multiply Algorithm shows the algorithm that is used. The 32-bit result is stored in four registers.

## 16x16 Unsigned Multiply Algorithm

RES3:RES0=ARG1H:ARG1LARG2H:ARG2L=(ARG1HARG2H216)+(ARG1HARG2L28)+(ARG1LARG2H28)+(ARG1LARG2L)

## 16x16 Unsigned Multiply Routine


MOVF    ARG1L, W
MULWF   ARG2L           ; ARG1L * ARG2L → PRODH:PRODL
MOVFF   PRODH, RES1     ;
MOVFF   PRODL, RES0     ;
;
MOVF    ARG1H, W        ;
MULWF   ARG2H           ; ARG1H * ARG2H → PRODH:PRODL
MOVFF   PRODH, RES3     ;
MOVFF   PRODL, RES2     ;
;
MOVF    ARG1L, W
MULWF   ARG2H           ; ARG1L * ARG2H → PRODH:PRODL
MOVF    PRODL, W        ;
ADDWF   RES1, F         ; Add cross products
MOVF    PRODH, W        ;
ADDWFC  RES2, F         ;
CLRF    WREG            ;
ADDWFC  RES3, F         ;
;
MOVF    ARG1H, W        ;
MULWF   ARG2L           ; ARG1H * ARG2L → PRODH:PRODL
MOVF    PRODL, W        ;
ADDWF   RES1, F         ; Add cross products
MOVF    PRODH, W        ;
ADDWFC  RES2, F         ;
CLRF    WREG            ;
ADDWFC  RES3, F         ;