PIC17C4X
Example 8-2 shows the sequence to do an 8 x 8 signed
multiply. To account for the sign bits of the arguments,
each argument’s most significant bit (MSb) is tested
and the appropriate subtractions are done.
8.0
HARDWARE MULTIPLIER
All PIC17C4X devices except the PIC17C42, have an
8 x 8 hardware multiplier included in the ALU of the
device. By making the multiply a hardware operation, it
completes in a single instruction cycle. This is an
unsigned multiply that gives a 16-bit result. The result
is stored into the 16-bit PRODuct register
(PRODH:PRODL). The multiplier does not affect any
flags in the ALUSTA register.
EXAMPLE 8-1: 8 x 8 MULTIPLY ROUTINE
MOVFP
MULWF
ARG1, WREG
ARG2
; ARG1 * ARG2 ->
PRODH:PRODL
;
Making the 8 x 8 multiplier execute in a single cycle
gives the following advantages:
EXAMPLE 8-2: 8 x 8 SIGNED MULTIPLY
ROUTINE
• Higher computational throughput
• Reduces code size requirements for multiply
algorithms
MOVFP
MULWF
ARG1, WREG
ARG2
; ARG1 * ARG2 ->
PRODH:PRODL
;
The performance increase allows the device to be used
in applications previously reserved for Digital Signal
Processors.
BTFSC
SUBWF
ARG2, SB
PRODH, F
; Test Sign Bit
; PRODH = PRODH
;
- ARG1
MOVFP
BTFSC
SUBWF
ARG2, WREG
ARG1, SB
PRODH, F
Table 8-1 shows a performance comparison between
the PIC17C42 and all other PIC17CXX devices, which
have the single cycle hardware multiply.
; Test Sign Bit
; PRODH = PRODH
;
- ARG2
Example 8-1 shows the sequence to do an 8 x 8
unsigned multiply. Only one instruction is required
when one argument of the multiply is already loaded in
the WREG register.
TABLE 8-1:
PERFORMANCE COMPARISON
Time
@ 25 MHz @ 33 MHz
Program Memory
Routine
Device
Cycles (Max)
(Words)
8 x 8 unsigned
PIC17C42
13
1
69
1
11.04 µs
160 ns
—
N/A
121 ns
N/A
All other PIC17CXX devices
PIC17C42
8 x 8 signed
—
6
—
All other PIC17CXX devices
6
960 ns
38.72 µs
3.84 µs
40.64 µs
5.76 µs
727 ns
N/A
16 x 16 unsigned PIC17C42
All other PIC17CXX devices
PIC17C42
All other PIC17CXX devices
21
24
52
36
242
24
254
36
2.91 µs
N/A
16 x 16 signed
4.36 µs
1996 Microchip Technology Inc.
DS30412C-page 49
This document was created with FrameMaker 4 0 4