Digital Signal Processing Reference
In-Depth Information
// Noisegen_casm.c Pseudorandom noise generation calling ASM function
#include "dsk6713_aic23.h"
//codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_48KHZ;
//set sampling rate
int previous_seed;
short pos = 16000, neg = -16000;
//scaling noise level
interrupt void c_int11()
{
previous_seed = noisefunc(previous_seed); //call ASM function
if(previous_seed & 0x01) output_sample(pos);//positive scaling
else output_sample(neg);//negative scaling
}
void main ()
{
comm_intr(); //init DSK,codec,McBSP
previous_seed = noisefunc(0x7E521603); //call ASM function
while (1);
//infinite loop
}
FIGURE 3.12. C program that calls an ASM function to generate a 32-bit noise sequence
( noisegen_casm.c ).
; Noisegen_casmfunc.asm Noise generation C-called function
.def _noisefunc ;ASM function called from C
_noisefunc ZERO A2 ;init A2 for seed manipulation
MV A4,A1 ;seed in A1
SHR A1,17,A1 ;shift right 17->bit 17 to LSB
ADD A1,A2,A2 ;add A1 to A2 => A2
SHR A1,11,A1 ;shift right 11->bit 28 to LSB
ADD A1,A2,A2 ;add again
SHR A1,2,A1 ;shift right 2->bit 30 to LSB
ADD A1,A2,A2 ;
SHR A1,1,A1 ;shift right 1->bit 31 to LSB
ADD A1,A2,A2 ;
AND A2,1,A2 ;Mask LSB of A2
SHL A4,1,A4 ;shift seed left 1
OR A2,A4,A4 ;Put A2 into LSB of A4
B B3 ;return to calling function
NOP 5 ;5 delays for branch
FIGURE 3.13. ASM function called from C to generate a 32-bit noise sequence
( noisegen_casmfunc.asm ).
Search WWH ::




Custom Search