Microchip Technology SW006022-1N Data Sheet

Page of 338
Device-Related Features
 2012 Microchip Technology Inc.
DS52071B-page 89
4.7
BIT-REVERSED AND MODULO ADDRESSING
Bit-reversed and modulo addressing is supported on all dsPIC devices.
Bit-reversed addressing is used for simplifying and speeding-up the writes to X-space 
data arrays in FFT (Fast Fourier Transform) algorithms. When enabled, pre-increment 
or post-increment addressing modes will reverse the lower order address bits used by 
instructions.
Modulo, or circular, addressing provides an automated means to support circular data 
buffers using the dsPIC hardware. When used, software no longer needs to perform 
data address boundary checks on arrays.
The compiler does not directly support the use of bit-reversed and modulo addressing; 
that is, it cannot generate code from C source that assumes these addressing modes 
are enabled when accessing memory. If either of these addressing modes are set up 
on the target device, then it is the programmer’s responsibility to ensure that the com-
piler does not use those registers that are specified to use either modulo or bit-reversed 
addressing as pointers. Particular care must be exercised if interrupts can occur while 
one of these addressing modes is enabled.
It is possible to define arrays in C that will be suitably aligned in memory for modulo 
addressing by hand-written assembly language functions. The aligned attribute may 
be used to define arrays that are positioned for use as incrementing modulo buffers. 
Initialization of the start and end addresses, as well as the registers that modulo 
address is applied must be written by hand to match the array specification. The 
reverse
 attribute may be used to define arrays that are positioned for use as decre-
menting modulo buffers. For more information on these attributes, see 
Section 10.2.1 “Function Specifiers”. For more information on bit-reversed or mod-
ulo addressing, see Chapter 3 of the “dsPIC30F Family Reference Manual” (DS70046).