Digital Signal Processing Reference
In-Depth Information
Partial programs C/ASM function to multiply 2 numbers using switches
..
while(m == 100) //check for first SW pressed
{
if(DSK6713_DIP_get(0)== 0) //true if SW0 is pressed
{
m = 1; //value if SW0 is pressed
while(DSK6713_DIP_get(0)==0) DSK6713_LED_on(0);//ON until released
for(delay=0; delay<5000000; delay++){} //debounce of SW0
}
else if(DSK6713_DIP_get(1)==0)
//true if SW1 is pressed
{
m = 2;
.
.
else m = 100;
.
.
while(ii == 0)
{
result = values(n, m); //result from ASM function in A4
led0 = result0(result); //returns a 0 or 1 to led0
if(led0==1) DSK6713_LED_on(0); //if led0 is 1 turn it on
.
.
;ASM function
..
_values:
MV A4,A5
;setup n as loop counter
MV B4,B1
LOOP: ADD A5,A4,A4 ;accumulate in A4
SUB B1,1,B1 ;decrement loop counter
[B1] B LOOP ;branch to LOOP if B1#0
NOP 5 ;five NOPs for delay slots
SUB A4,A5,A4 ;answer into A4
B B3
;return to calling routine
NOP 5
;five NOPs for delay slots
_result0: SHL A4,31,A4 ;shift left 31 bits to keep LSB
SHRU A4,31,A4 ;shift right 31 bits to make A4=0 or 1
B B3 ;return to calling routine
NOP 5 ;five NOPs for delay slots
FIGURE 3.25. Partial programs (C and ASM function) to multiply two numbers using the
dip switches.
seed is treated as a theoretical bit. The “tap points” are chosen as shown (bits
1, 2, 11, 15, and 16) to produce a large string of random numbers [11]. Within
the asm or linear asm function, each integer value is taken as a seed, and you
can use instructions such as LDW/STW, repeated 15 times, to move each seed
“up.” XOR bits 1 and 2, the result of which is XORed with bit 11, and so on,
as shown in Figure 3.26. The resulting seed generated is placed at the “bottom”
Search WWH ::




Custom Search