PIC18F2450/4450
7.0
7.1
8 x 8 HARDWARE MULTIPLIER
Introduction
EXAMPLE 7-1:
MOVF
MULWF
ARG1, W
ARG2
8 x 8 UNSIGNED
MULTIPLY ROUTINE
;
; ARG1 * ARG2 ->
; PRODH:PRODL
All PIC18 devices include an 8 x 8 hardware multiplier
as part of the ALU. The multiplier performs an unsigned
operation and yields a 16-bit result that is stored in the
product register pair, PRODH:PRODL. The multiplier’s
operation does not affect any flags in the STATUS
register.
Making multiplication a hardware operation allows it to
be completed in a single instruction cycle. This has the
advantages of higher computational throughput and
reduced code size for multiplication algorithms and
allows the PIC18 devices to be used in many applica-
tions previously reserved for digital signal processors.
A comparison of various hardware and software
multiply operations, along with the savings in memory
and execution time, is shown in Table 7-1.
EXAMPLE 7-2:
MOVF
MULWF
BTFSC
SUBWF
MOVF
BTFSC
SUBWF
ARG1, W
ARG2
ARG2, SB
PRODH, F
ARG2, W
ARG1, SB
PRODH, F
8 x 8 SIGNED MULTIPLY
ROUTINE
;
;
;
;
;
ARG1 * ARG2 ->
PRODH:PRODL
Test Sign Bit
PRODH = PRODH
- ARG1
; Test Sign Bit
; PRODH = PRODH
;
- ARG2
7.2
Operation
8 x 8 unsigned multiplication. Only one instruction is
required when one of the arguments is already loaded
in the WREG register.
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.
TABLE 7-1:
Routine
PERFORMANCE COMPARISON FOR VARIOUS MULTIPLY OPERATIONS
Multiply Method
Without hardware multiply
Hardware multiply
Without hardware multiply
Hardware multiply
Without hardware multiply
Hardware multiply
Without hardware multiply
Hardware multiply
Program
Memory
(Words)
13
1
33
6
21
28
52
35
Cycles
(Max)
69
1
91
6
242
28
254
40
Time
@ 40 MHz
6.9
μs
100 ns
9.1
μs
600 ns
24.2
μs
2.8
μs
25.4
μs
4.0
μs
@ 10 MHz
27.6
μs
400 ns
36.4
μs
2.4
μs
96.8
μs
11.2
μs
102.6
μs
16.0
μs
@ 4 MHz
69
μs
1
μs
91
μs
6
μs
242
μs
28
μs
254
μs
40
μs
8 x 8 unsigned
8 x 8 signed
16 x 16 unsigned
16 x 16 signed
©
2006 Microchip Technology Inc.
Advance Information
DS39760A-page 83