14 Software Examples
14 – 18
14.7.3
Bit-Reverse Subroutine
The bit-reversal routine, called scramble, puts the input data in bit-
reversed order so that the results will be in sequential order. This routine
uses the bit-reverse capability of the ADSP-2100 family processors.
.MODULE
dit_scramble;
{
Calling Parameters
Sequentially ordered input data in inputreal
Return Values
Scrambled input data in inplacereal
Altered Registers
I0,I4,M0,M4,AY1
Altered Memory
inplacereal
}
.CONST
N=1024,mod_value=H#0010; {Initialize constants}
.EXTERNAL
inputreal, inplacereal;
.ENTRY
scramble;
scramble:
I4=^inputreal;
{I4—>sequentially ordered data}
I0=^inplacereal;
{I0—>scrambled data}
M4=1;
M0=mod_value;
{M0=modifier for reversing N bits}
L4=0;
L0=0;
CNTR = N;
ENA BIT_REV;
{Enable bit-reversed outputs on DAG1}
DO brev UNTIL CE;
AY1=DM(I4,M4);
{Read sequentially ordered data}
brev:
DM(I0,M0)=AY1;
{Write data in bit-reversed location}
DIS BIT_REV;
{Disable bit-reverse}
RTS;
{Return to calling program}
.ENDMOD;
Listing 14.7 Bit-Reverse Routine (Scramble)