Sunteți pe pagina 1din 30

PROGRAM:

%Generation of Basic signals


%Clear the screen
clc;
clear all;
close all;

%Unit impulse signal


t=-2:1:2;
y=[zeros(1,2),ones(1,1),zeros(1,2)];
subplot(2,2,1);
stem(t,y);
title('Unit impulse signal');
ylabel('amplitude');
xlabel('a(n)');

%Unit step signal


n=input('enter the N value:');
t=0:1:n-1;
y1=ones(1,n);
subplot(2,2,2);
stem(t,y1);
title('Unit step signal');
ylabel('amplitude');
xlabel('b(n)');

%Unit ramp signal


n1=input('enter the length of Ramp sequence:');
t=0:1:n1;
subplot(2,2,3);
stem(t,t);
title('Ramp signal');
xlabel('c(n)');
ylabel('amplitude');

%Unit Exponential Signal


n2=input('enter the length of exponential sequence:');
t=0:1:n2;
a=input('enter the a value:');
y2=exp(a*t);
subplot(2,2,4);
stem(t,y2);
title('Exponential signal');
ylabel('amplitude');
xlabel('d(n)');
INPUT:

enter the N value:7


enter the length of Ramp sequence:8
enter the length of exponential sequence:9
enter the a value:.3

GENERATION OF BASIC SIGNAL


PROGRAM:

% PROGRAM FOR LINEAR CONVOLUTION

% Clear the screen


clc;
clear all;
close all;

% Get the input sequence


x=input('enter the first sequence:');
h=input('enter the second sequence');
% Generate the convolved signal
y=conv(x,h);
figure;

% Plot the signal


subplot(3,1,1);
stem(x);
title('input sequence');
ylabel('amplitude');
xlabel('x(n)');
subplot(3,1,2);
stem(h);
title('impulse sequence');
ylabel('amplitude');
xlabel('h(n)');
subplot(3,1,3);
stem(y);
title('output sequence');
ylabel('amplitude');
xlabel('y(n)');
subplot(3,1,3);
disp('the resultant signal is :');y
% PROGRAM FOR CIRCULAR CONVOLUTION

% Get the input sequence


x=input('enter the first sequence:');
h=input('enter the second sequence');

% Calculate the length of the sequence


N1=length(x);
N2=length(h);
% Generate the circularly convolved sequence
N=max(N1,N2);
N3=N1-N2;
figure;
if(N3>=0)
h=[h,zeros(1,N3)];
else
x=[x,zeros(1,N3)];
end

%Computation of circular convolved sequence


for n=1:N;
sum=0;
for i=1:N;
j=n-i+1;
if(j<=0)
j=N+j;
end
sum=sum+(x(i)*h(j));
end
y1(n)=sum;
end

%Plot the input


subplot(1,3,1);
stem(x);
title('input sequence');
ylabel('amplitude');
xlabel('x(n)');
subplot(1,3,2);
stem(h);
title('impulse sequence');
ylabel('amplitude');
xlabel('h(n)');

%Plot the output


subplot(1,3,3);
stem(y1);
title('output sequence');
ylabel('amplitude');
xlabel('y1(n)');

%Display the output sequences values


disp('the circular convolution output is :');y1
Linear convolution

Input:
enter the first sequence:[1,2,3,1]
enter the second sequence[1,2,2,1]

Output:
The resultant signal is :

y= 1 4 9 12 10 5 1

LINEAR CONVOLUTION

input sequence
4
amplitude

0
1 1.5 2 2.5 3 3.5 4
x(n)
impulse sequence
2
amplitude

0
1 1.5 2 2.5 3 3.5 4
h(n)
output sequence
20
amplitude

10

0
1 2 3 4 5 6 7
y(n)
Circular Convolution

Input:
enter the first sequence:[1,2,3,1]
enter the second sequence[1,2,2,1]

Output:
The circular convolution output is :

y1 = 11 9 10 12

CIRCULAR CONVOLUTION

input sequence impulse sequence output sequence


3 2 12

1.8
2.5 10
1.6

1.4
2 8
1.2
amplitude

amplitude

amplitude

1.5 1 6

0.8
1 4
0.6

0.4
0.5 2
0.2

0 0 0
0 2 4 0 2 4 0 2 4
x(n) h(n) y1(n)
PROGRAM:

% FAST FOURIER TRANSFORM

%Clear the screen


clc;
close all;
clear all;

%Read the input sequence


x=input('Enter the input sequence:');
%Read the length of FFT
M=input('Enter the FFT length:');

%Calculate the FFT values


y=fft(x,M);
%Plot the input
subplot(1,3,1);
stem(x);
grid;
title('Input sequence');
xlabel('n');
ylabel('y(n)');

%plot the real output


subplot(1,3,2);
stem(real(y));
grid;
title('Real output sequence');
xlabel('n');
ylabel('y(n)');

%plot the imaginary output


subplot(1,3,3);
stem(angle(y));
grid;
title('Imaginary output sequence');
xlabel('n');
ylabel('y(n)');

%Display the FFT outputs


disp('The output of FFT sequences:');y
Input:

Enter the input sequence:[1,3,4,5,6,8,3,4]


Enter the FFT length: 8

Output:

The output of FFT sequences:

y = Columns 1 through 5

34.0000 -9.2426 + 1.8284i 0 - 2.0000i -0.7574 + 3.8284i -6.0000

Columns 6 through 8

-0.7574 - 3.8284i 0 + 2.0000i -9.2426 - 1.8284i

FAST FOURIER TRANSFORM

Input sequence Real output sequence Imaginary output sequence


8 35 4

7 30
3

25
6
2
20
5
15 1
4
y(n)

y(n)

y(n)

10 0
3
5
-1
2
0

1 -2
-5

0 -10 -3
0 5 10 0 5 10 0 5 10
n n n
PROGRAM:

%Sampling Theorem
clc;
close all;
clear all;

f1=1/128;f2=5/128;n=0:255;fc=50/128;
x=cos(2*pi*f1*n)+cos(2*pi*f2*n);
xa=cos(3*pi*fc*n);
xamp=x.*xa;
subplot(2,2,1);
plot(n,x);
title('Modulating signal');
xlabel('time');
ylabel('amplitude');
subplot(2,2,2);
plot(n,xa);
title('Carrier signal');
xlabel('time');
ylabel('amplitude');
subplot(2,2,3);
plot(n,xamp);
title('Modulated signal');
xlabel('time');
ylabel('amplitude');

%128 point DFT compution solution


n=0:127;figure;n1=128;
x=cos(2*pi*f1*n)+cos(2*pi*f2*n);
xa=cos(2*pi*fc*n);
xamp=x.*xa;
xam=fft(xamp,n1);
stem(n,xam);
title('128 point signal');
xlabel('time');
ylabel('amplitude');

%100 point DFT compution solution


n=0:99;figure;n2=0:127;
f1=1/128;f2=5/128;fc=50/128;
x=cos(2*pi*f1*n)+cos(2*pi*f2*n);
xa=cos(2*pi*fc*n);
xamp=x.*xa;
for i=1:100
xamp1(i)=xamp(i);
end
xam=fft(xamp,n1);
stem(n2,xam);
title('100 point signal');
xlabel('time');
ylabel('amplitude');
SAMPLING THEOREM

FIGURE: 1

Modulating signal Carrier signal


2 1

1 0.5

0 0
plitude

plitude
am

am
-1 -0.5

-2 -1
0 100 200 300 0 100 200 300
time time
Modulated signal
2

0
amplitude

-1

-2
0 100 200 300
time
SAMPLING THEOREM

FIGURE: 2

128 point signal


35

30

25

20
a m p litu d e

15

10

-5
0 20 40 60 80 100 120 140
time

SAMPLING THEOREM

FIGURE: 3

100 point signal


30

25

20

15
amplitude

10

-5

-10

-15
0 20 40 60 80 100 120 140
time
PROGRAM:
%Design FIR filter using Rectangular window
% Clear the screen
clc;
close all;
clear all;
n=input('Enter the order of the filter: ');
wn=input('Enter cut off frequency: ');
wn1=input('Enter the cut off frequencies Wn1,Wn2: ');
w=boxcar(n+1);

%Low Pass filter


b=fir1(n,wn,w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,1);
plot(om/pi,mag);
title('Low pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');

%High Pass filter


b=fir1(n,wn,'high',w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,2);
plot(om/pi,mag);
title('high pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');

%Band Pass filter


b=fir1(n,wn1,w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,3);
plot(om/pi,mag);
title('Band pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');

%Band stop filter


b=fir1(n,wn1,'stop',w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,4);
plot(om/pi,mag);
title('Bandstop filter');
xlabel('Normalized frequency');
ylabel('Gain in db');
disp('output of b');b
Input:

Enter the order of the filter: 12


Enter cut off frequency: .5
Enter the cut off frequencies Wn1, Wn2: [.4, .6]

Output:
Output of b =

Columns 1 through 9

0.0940 0.0000 -0.1410 0.0000 0.1743 0.0000 0.7454 0.0000 0.1743

Columns 10 through 13

0.0000 -0.1410 0.0000 0.0940

RECTANGULAR WINDOW

Low pass filter high pass filter


50 50

0 0
Gain in DB

Gain in DB

-50 -50

-100 -100
0 0.5 1 0 0.5 1
Normalized frequency Normalized frequency
Band pass filter Bandstop filter
20 20

0 0
Gain in DB

Gain in DB

-20 -20

-40 -40

-60 -60
0 0.5 1 0 0.5 1
Normalized frequency Normalized frequency
PROGRAM:
%Design FIR filter using Hamming window
%Clear the screen
clc;
close all;
clear all;
n=input('Enter the order of the filter: ');
wn=input('Enter cut off frequency: ');
wn1=input('Enter the cut off frequencies Wn1,Wn2: ');
w=hamming(n+1);

%Low Pass filter


b=fir1(n,wn,w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,1);
plot(om/pi,mag);
title('Low pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');

%High Pass filter


b=fir1(n,wn,'high',w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,2);
plot(om/pi,mag);
title('high pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');

%Band Pass filter


b=fir1(n,wn1,w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,3);
plot(om/pi,mag);
title('Band pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');

%Band stop filter


b=fir1(n,wn1,'stop',w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,4);
plot(om/pi,mag);
title('Bandstop filter');
xlabel('Normalized frequency');
ylabel('Gain in db');
disp('output of b');b
Input:

Enter the order of the filter: 12


Enter cut off frequency: .5
Enter the cut off frequencies Wn1,Wn2: [.4,.6]

Output:

Output of b =

Columns 1 through 9

0.0080 0.0000 -0.0464 0.0000 0.1426 0.0000 0.7917 0.0000 0.1426

Columns 10 through 13

0.0000 -0.0464 0.0000 0.0080

HAMMING WINDOW

Low pass filter high pass filter


50 50

0 0
Gain in DB

Gain in DB

-50 -50

-100 -100
0 0.5 1 0 0.5 1
Normalized frequency Normalized frequency
Band pass filter Bandstop filter
0 5

-20
0
Gain in DB

Gain in DB

-40
-5
-60

-80 -10
0 0.5 1 0 0.5 1
Normalized frequency Normalized frequency
PROGRAM:
%Design FIR filter using Hanning window
%Clear the screen
clc;
close all;
clear all;
n=input('Enter the order of the filter: ');
wn=input('Enter cut off frequency: ');
wn1=input('Enter the cut off frequencies Wn1,Wn2: ');
w=hanning(n+1);

%Low Pass filter


b=fir1(n,wn,w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,1);
plot(om/pi,mag);
title('Low pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');

%High Pass filter


b=fir1(n,wn,'high',w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,2);
plot(om/pi,mag);
title('high pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');

%Band Pass filter


b=fir1(n,wn1,w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,3);
plot(om/pi,mag);
title('Band pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');

%Band stop filter


b=fir1(n,wn1,'stop',w);
[h,om]=freqz(b,1,256);
mag=20*log10(abs(h));
%plot the output
subplot(2,2,4);
plot(om/pi,mag);
title('Bandstop filter');
xlabel('Normalized frequency');
ylabel('Gain in db');
disp('output of b');b
Input:

Enter the order of the filter: 18


Enter cut off frequency: .6
Enter the cut off frequencies Wn1, Wn2: [.3, .7]

Output:
output of b =

Columns 1 through 9

0.0000 0.0073 -0.0000 -0.0216 0.0000 -0.0614 0.0000 0.2748 0.0000

Columns 10 through 18

0.6021 0.0000 0.2748 0.0000 -0.0614 0.0000 -0.0216 -0.0000 0.0073

Column 19

0.0000

HANNING WINDOW

Low pass filter high pass filter


50 50

0
0
Gain in DB

Gain in DB

-50
-50
-100

-100 -150
0 0.5 1 0 0.5 1
Normalized frequency Normalized frequency
Band pass filter Bandstop filter
0 50

-20
0
Gain in DB

Gain in DB

-40
-50
-60

-80 -100
0 0.5 1 0 0.5 1
Normalized frequency Normalized frequency
PROGRAM:

%Design IIR Filter using Butterworth filter


%Clear the screen
clc;
close all;
clear all;
n=input('Enter the order of the filter: ');
wn=input('Enter cut off frequency: ');
wn1=input('Enter the cut off frequencies Wn1,Wn2: ');

%Low Pass filter


[b,a]=butter(n,wn);
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
mag=20*log10(abs(h));
%plot the output
an=angle(h);
figure(1);
subplot(2,2,1);
plot(om/pi,mag);
title('Low pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');
subplot(2,2,2);
plot(om/pi,an);
xlabel('Normalized frequency');
ylabel('Phase in radians');

%High Pass filter


[b,a]=butter(n,wn,'high');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
mag=20*log10(abs(h));
%plot the output
an=angle(h);
subplot(2,2,3);
plot(om/pi,mag);
title('High pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');
subplot(2,2,4);
plot(om/pi,an);
xlabel('Normalized frequency');
ylabel('Phase in radians');

%Band Pass filter


[b,a]=butter(n,wn1);
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
mag=20*log10(abs(h));
%plot the output
an=angle(h);
figure(2);
subplot(2,2,1);
plot(om/pi,mag);
title('Band pass filter');
xlabel('Normalized frequency');
ylabel('Gain in db');
subplot(2,2,2);
plot(om/pi,an);
xlabel('Normalized frequency');
ylabel('Phase in radians');

%Band stop filter


[b,a]=butter(n,wn1,'stop');
w=0:0.01:pi;
[h,om]=freqz(b,a,w);
mag=20*log10(abs(h));
%plot the output
an=angle(h);
subplot(2,2,3);
plot(om/pi,mag);
title('Band stop filter');
xlabel('Normalized frequency');
ylabel('Gain in db');
subplot(2,2,4);
plot(om/pi,an);
xlabel('Normalized frequency');
ylabel('Phase in radians');
disp('output');[b,a]

Input:

Enter the order of the filter: 12


Enter cut off frequency: .5
Enter the cut off frequencies Wn1, Wn2: [.4, .8]

Output:

ans = Columns 1 through 9


0.0051 0.0465 0.2561 1.0086 3.1424 8.0770 17.6733 33.4957 55.7576

Columns 10 through 18
82.2008 108.0509 127.0999 134.1508 127.0999 108.0509 82.2008 55.7576 33.4957

Columns 19 through 27
17.6733 8.0770 3.1424 1.0086 0.2561 0.0465 0.0051 1.0000 5.4979

Columns 28 through 36
16.4646 35.3450 61.1848 89.9227 115.1711 130.5669 132.6060 121.5685 101.0611

Columns 37 through 45
76.3656 52.5289 32.8800 18.6958 9.6240 4.4647 1.8532 0.6817 0.2191

Columns 46 through 50
0.0604 0.0138 0.0025 0.0003 0.0000
BUTTERWORTH FILTER
FIGURE:1

Low pass filter


200 4

Phase in radians
2
0
Gain in DB

0
-200
-2

-400 -4
0 0.5 1 0 0.5 1
Normalized frequency Normalized frequency
High pass filter
200 4

Phase in radians
2
0
Gain in DB

0
-200
-2

-400 -4
0 0.5 1 0 0.5 1
Normalized frequency Normalized frequency

BUTTERWORTH FILTER
FIGURE:2

Band pass filter


0 4
Phase in radians

-100 2
Gain in DB

-200 0

-300 -2

-400 -4
0 0.5 1 0 0.5 1
Normalized frequency Normalized frequency
Band stop filter
100 4
Phase in radians

0 2
Gain in DB

-100 0

-200 -2

-300 -4
0 0.5 1 0 0.5 1
Normalized frequency Normalized frequency
PROGRAM: (Addition)

.include”5416_iv.asm”
.def start
.data
.word 0003h,0004h
.text

Start STM #1500h,AR1


STM #1501h,AR2
STM #1502h,AR3
LD *AR1,A
LD *AR2,B
ADD A,0,B
STL B,*AR3
Wait B Wait

Input:

1500=0003
1501=0004

Output:

1502=0007

PROGRAM: (Subtraction)

.include”5416_iv.asm”
.def start
.data
.word 0004h,0003h
.text

Start STM #1500h,AR1


STM #1501h,AR2
STM #1502h,AR3
LD *AR1,A
LD *AR2,B
SUB A,0,B
STL B,*AR3
Wait B Wait

Input:

1500=0004
1501=0003

Output:

1502=0001
PROGRAM: (Multiplication)

.include”5416_iv.asm”
.def start
.data
.word 0003h,0004h
.text

Start STM #1500h,AR3


STM #1501h,AR5
STM #1504h,AR2
MPY *AR3,*AR5,B
STL B,*AR2
Wait B Wait

Input:

1500=0003
1501=0004

Output:

1504=000C

PROGRAM: (Division)

.include”5416_iv.asm”
.def start
.data
.word FFFFh,0002h
.text

Main RSBX SXM


STM #1000h,AR0
STM #2000h,AR1
LD *AR0+,A
RPT #15
SUBC *AR0,A
STL A,*AR1+
STH A,*AR1
Wait B Wait

Input:

1000=FFFF
1001=0002

Output:

2000=7FFF
2001=0001
PROGRAM: (IIR filter)

.include”5416_iv.asm”
.def start
.data
Pole .word a7e 3h,154fh
Azero .word 0b4ch,1698h,064ch
Xin .word 0,0
Xout .word 0
.text
.include”500.asm”

Start LD #b pole,DP
STM #3000h,AR3
STM #4000h,AR4
STM #5000h,AR1
STM #6000h,AR2
STM #8000h,AR0
STM #7000h,AR5
STM #80h,BRL

RPTB LOOP
NTAR *AR2+
RPT #02h
MACD *AR2-,Azero,A
STH A,0,*AR0
LD #0h,A
MVDD *AR5+,*AR4+
RPT #01h
MACD *AR4-,b Pole A
RPT #01h
MACD *AR4-,b Pole A
STH A,0,*AR7
LD *AR0,A
LD *AR7,B
ADD B,0,A
STA A,*AR5
RPT #01h
MAR *AR4+
MAR *AR2+
MAR *AR7+
MAR *AR0+

LOOP MAR *AR0+


NOP

.end
PROGRAM: (FIR Filter)

.include”5416_iv.asm”
.def start
.data
.word 086eh,0b9eh,0e5fh,1064h,
176h,1064h, 0e5fh, 0b9eh, 086eh
.text

COEFF .include”s500.asm”

Start STM #100h,AR5

STM #3000h,AR3

STM #5000h,AR1

STM #80h,BRC

RPTB LOOP

MVDD *AR5+,*AR3

RPT #08h

MAR *AR3+

RPT #09h

MACD *AR3-,COEFF,A

STH A,0,*AR1+

LOOP MAR *AR3+

.end
PROGRAM:(FFT)

.include”twi.asm”
.include”twr.asm”
.include”cos.asm”
.include”5416_iv.asm”
.def start
.data
R1 .word 0h ;variables
I1 .word 0h
Stages .word 7h
Grp .word 0h
Grp1 .word 0h
but .word 1h
but1 .word 0h
R .word 0h
I .word 0h
A1 .word 0h
sizetw .word 40h
sizein .word 80h
bitr .word 40h
shi .word 7Fh
CNT .word 128
E .word 45h
.text

Start LD #R1,DP
RSBX INTM
LD #022Bh,0,A
STLM A,P,MST

RSBX INTM
LD #01 7h,0,A
STLM A,IMR
STM #0h,McBSP0_DXR1
STM #0h,McBSP0_DXR2
STM #0007h,GPIOCR
STM #0003h,GPIOSR
STM #SPCR2,McBSP2_SPSA
STM #00E1h,McBSP2_SPSD ;Mclk
NOP
STM #007h,GPIOSR
STM #SPCR2,McBSPO_SPSA
STM #00E1h,McSPSD ;Sclk & Fs
STM #1000h,AR6 ;FFT I/P
STM #1800h,AR1 ;FFT O/P
SSBX SXM
RSBX OVM
LD #0h,0,A
RPT #127
STL A,*AR1+
STM #1800h,AR1
STM #3500h,AR7

WAIT NOP
NOP
LD CNT,B
BC FFT,BEQ
NOP
NOP
B WAIT

_RINT0_ISR
PSHM AL
PSHM AH
PSHM AG
PSHM BL
PSHM BH
PSHM BG

LD *AR6+,0,A
STLM A,McBSP0_DXR1 ;O/P for R channel
STLM A,McBSP0_DXR2 ;O/P for L channel
LD CNT,B
SUB #IH,0,B
STL B,0,BNT

POPM BG
POPM BH
POPM BL
POPM AG
POPM AL
RETE
FET NOP
NOP
LD #0,A
STLM A,IMR
STM #1000h,AR6
STM #1800h,AR1
STM #2000h,AR4
STM #1000h,AR3
RPT #127
MVDD *AR4+,*AR3+
LD #R1,DP
NOP
LD #80h,A
STL A,CNT
NOP
PORTW E,0

;----------------Bit Reversal-----------------------------------------------
;----------------For 128pt FFT the index value is 128/2=64(40h)----

STM #0040h,AR0 ;Index


STM #2400h,AR4 ;Bit reversed o/p
NOP
NOP
RPT #127
MVPD #200h,*AR4+0,B ;Bit reversal

NOP
NOP
STM #2400h,AR5
LD #0h,0,A
STM #2800h,AR3
RPT #127
STL A,0,*AR3+
STM #3000h,AR3 ;TWIDDLE REAL
STM #3400h,AR4 ;TWIDDLE IMAG
STM #40h,BK
-----------------------------------Butterfly loop Begins-------------------------------------

SU LD Stages,0,A
LD Grp,0,B
STL B,Grp1
LD but,0,A
STM #2400h,AR5
STM #2800h,AR2

GU LD #40h,B
STLM B,BK
LD but,0,A
STL A,but1
LD #0h,0,B
SUB A,0,B
STL B,A1
STM #3000h,AR3
STM #3400h,AR4

BU LD #80h,B
STLM B,BK
LD *AR5,0,A
LD *AR2,0,B
STL A,0,R
STL B,0,I
LF but,0,S
DTLM S,SR0
NOP
NOP
MAR *AR5+0%
MAR *AR2+0%
MAR *AR3,*AR5,A
MAR *AR4,*AR2,B
SUB B,0,A
STH A,R1
MPY *AR3,*AR3,A
MPY *AR4,*AR5,B
ADD A,0,B
STH B,I1
LD R,-1,A
LD R1,0,B
SUB B,0,A
STL A,*AR5
LD I,-1,A
LD I1,0,B
SUB B,0,A
STL A,*AR2
NOP
NOP
NOP
LD A1,0,B
STLM B,AR0
NOP
NOP
MAR *AR5+0%
MAR *AR2+0%
LD R,-1,A
LD R1,0,B
ADD B,0,A
STL A,*AR5+
LD I,-1,A
LD I1,0,B
SUB B,0,A
STL A,*AR2+ ;BUT
NOP
LD #40h,0,B
STLM B,BK
LD Grp,0,A
STLM A,AR0
NOP
NOP
NOP
NOP
MAR *AR3+0%
MAR *AR4+0%

LD but1,0,B
SUB #1h,0,B
STL B,0,but1
BC BU,BNEQ ;;;;;;;;;;;;;;Butterfly end

LD #80h,B
STLM B,BK
NOP
NOP
NOP
LD but,0,B
STLM B,AR0
NOP
NOP
MAR *AR5+0%
MAR *AR2+0%
LD Grp1,0,B
SUB #1h,0,B
STL B,Grp1
BC GU,BNEQ ;;;;;;;;;;;;;;Group end
NOP
LD but,0,B
SFTA B,1
STL B,but
STL B,but1
LD Grp,0,B
SFTA B,-1
STL B,Grp
STL B,Grp1

LD Stages,0,a
SUB #1h,0,a
STL A,Stages
BC SU,ANEQ ;;;;;;;;;;;;;;STAGES

LD #0h,0,A
LD #0h,0,B

----------------------------------Initialization of Variables-------------------------------------------

LD #7h,0,B
STL B,Stages
LD #40h,0,A
STL A,Grp
LD #1h,0,B
STL B,but
STM #2400h,AR3
STM #1800h,AR6
STM #7Fh,BRC
RPTB VE
LD *AR3+,A
ABS A
STL A,*AR6+
NOP

VE NOP
NOP
STM #1800h,AR6
LD #001h,A
STLM A,IMR
NOP
NOP
B WAIT
INTERFACING
PROGRAMS

S-ar putea să vă placă și