# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# PIC24FJ64GA004 - Programmers Reference Manual

- 1
- 2
…
- 79
- 80
- 81
- 82
- 83
…
- 501
- 502

© 2005-2011 Microchip Technology Inc. DS70157F-page 81
Section 4. Instruction Set Details
Instruction Set
Details
4
4.11 DSP DATA FORMATS (dsPIC30F, dsPIC33F AND dsPIC33E DEVICES)
4.11.1 Integer and Fractional Data
The dsPIC30F, dsPIC33F, and dsPIC33E devices support both integer and fractional data types.
Integer data is inherently represented as a signed two’s complement value, where the Most
Significant bit is defined as a sign bit. Generally speaking, the range of an N-bit two’s complement
integer is -2
N-1
to 2
N-1
– 1. For a 16-bit integer, the data range is -32768 (0x8000) to 32767
(0x7FFF), including ‘0’. For a 32-bit integer, the data range is -2,147,483,648 (0x8000 0000) to
2,147,483,647 (0x7FFF FFFF).
Fractional data is represented as a two’s complement number, where the Most Significant bit is
defined as a sign bit, and the radix point is implied to lie just after the sign bit. This format is
commonly referred to as 1.15 (or Q15) format, where 1 is the number of bits used to represent
the integer portion of the number, and 15 is the number of bits used to represent the fractional
portion. The range of an N-bit two’s complement fraction with this implied radix point is -1.0 to
(1 – 2
1-N
). For a 16-bit fraction, the 1.15 data range is -1.0 (0x8000) to 0.999969482 (0x7FFF),
including 0.0 and it has a precision of 3.05176x10
-5
. In Normal Saturation mode, the 32-bit
accumulators use a 1.31 format, which enhances the precision to 4.6566x10
-10
.
The dynamic range of the accumulators can be expanded by using the 8 bits of the Upper
Accumulator register (ACCxU) as guard bits. Guard bits are used if the value stored in the
accumulator overflows beyond the 32
nd
bit, and they are useful for implementing DSP
algorithms. This mode is enabled when the ACCSAT bit (CORCON<4>) is set to ‘1’ and it
expands the accumulators to 40 bits. The guard bits are also used when the accumulator
saturation is disabled. The accumulators then support an integer range of -5.498x10
11
(0x80
0000 0000) to 5.498x10
11
(0x7F FFFF FFFF). In Fractional mode, the guard bits of the
accumulator do not modify the location of the radix point and the 40-bit accumulators use a 9.31
fractional format. Note that all fractional operation results are stored in the 40-bit Accumulator,
justified with a 1.31 radix point. As in Integer mode, the guard bits merely increase the dynamic
range of the accumulator. 9.31 fractions have a range of -256.0 (0x80 0000 0000) to
(256.0 – 4.65661x10
-10
) (0x7F FFFF FFFF). Table 4-10 identifies the range and precision of
integers and fractions on the dsPIC30F/33F/33E devices for 16-bit, 32-bit and 40-bit registers.
It should be noted that, with the exception of DSP multiplies, the ALU operates identically on
integer and fractional data. Namely, an addition of two integers will yield the same result (binary
number) as the addition of two fractional numbers. The only difference is how the result is
interpreted by the user. However, multiplies performed by DSP operations are different. In these
instructions, data format selection is made by the IF bit (CORCON<0>), and it must be set
accordingly (‘0’ for Fractional mode, ‘1’ for Integer mode). This is required because of the implied
radix point used by dsPIC30F/33F/33E fractional numbers. In Integer mode, multiplying two
16-bit integers produces a 32-bit integer result. However, multiplying two 1.15 values generates
a 2.30 result. Since the dsPIC30F, dsPIC33F, and dsPIC33E devices use a 1.31 format for the
accumulators, a DSP multiply in Fractional mode also includes a left shift of one bit to keep the
radix point properly aligned. This feature reduces the resolution of the DSP multiplier to 2
-30
, but
has no other effect on the computation (e.g., 0.5 x 0.5 = 0.25).
Table 4-10: dsPIC30F/33F/33E Data Ranges
Register Size Integer Range Fraction Range Fraction Resolution
16-bit -32768 to 32767 -1.0 to (1.0 – 2
-15
) 3.052 x 10
-5
32-bit -2,147,483,648 to
2,147,483,647
-1.0 to (1.0 – 2
-31
) 4.657 x 10
-10
40-bit -549,755,813,888 to
549,755,813,887
-256.0 to (256.0 – 2
-31
) 4.657 x 10
-10

- 1
- 2
…
- 79
- 80
- 81
- 82
- 83
…
- 501
- 502