/
/
/ FFT PART 1
/
*200
START,	CLA HLT 	/SETUPS
	TAD N
	CIA
	DCA MN
	TAD MN
	TAD MN
	DCA MTWON
	TAD RLPTR 	/SET STORAGE AREA TO 0000
	DCA AI10
	TAD MTWON
	DCA CNT1
	DCA I AI10
	ISZ CNT1 	/ALL?
	JMP .-2
/
/
/ SAMPLING ROUTINE
/ BIT 0 DOWN MEANS USE TIMED SAMPLING
/ BIT 0 UP MEANS SAMPLE ON RC TICK
/
SAMPLR,TAD RLPTR
	DCA AI10
	TAD CHANNEL
	ACMX 		/SELECT CHANNEL
	CLR
	TAD MN
	DCA CNT3
	TAD R1 	/SET RELAY 1 FOR DURATION OF SAMPLING
	OTEN
/
	LAS
	SPA CLA 	/IS BIT 0 UP?
	JMP CLKSAM 	/YES
TIMSAM,ADCV 		/CONVERT
	SKAD 		/DONE?
	JMP .-1 	/NO, WAIT
	RADC 		/YES, READ IT
	DCA I AI10 	/PUT IT AWAY
/ROUTINE TO WAIT 0.01 SEC
	TAD K3537
	DCA CNT1
	ISZ CNT1
	JMP .-1 	/STALL
	ISZ CNT3 	/ALL SAMPLES TAKEN?
	JMP TIMSAM
	JMP ENDSAM
/
/
CLKSAM,NOP 		/COULD BE TAD SKEN
/ /(=4000) TO SLOW THE CLOCK DOWN
	TAD CVEN 	/(=2000) TO START CONVERSION ON TICK
	TAD CNEN 	/(=0002) TO ENABLE RC COUNT CHAIN
	OTEN 		/WHATEVER TURNS YOU ON!!
/
	CLRK
TIKSAM,SKRK 		/WAIT FOR A TICK
	JMP .-1
	CLRK
/
	SKAD 		/WAIT FOR COMPLETE CONVERSION
	JMP .-1
	RADC
	DCA I AI10
	ISZ CNT3 	/ALL IN?
	JMP TIKSAM
ENDSAM,ZTEN 		/DISABLE THE ENABLE REGISTER
/
/
/
/ DISPLAY INPUT WAVEFORM
/ FIRST HALF IN UPPER PORTION OF SCREEN
/ SECOND HALF IN LOWER PORTION OF SCREEN
/
INDISP,MTWO
	DCA CNT3 	/NUMBER OF HALVES
	TAD RLPTR
	DCA AI10
	TAD K200
DIS1,	DCA OFFSET 	/SET FOR 1/2 OF SCREEN
	TAD M1000 	/POINTS ALONG X AXIS
	DCA CNT1
	DCA HORIZ 	/STARTING X
DISPLA,TAD HORIZ
	DXCDXL
	ISZ HORIZ
	CLR
	TAD I AI10 	/GET A SAMPLE
	HALF 		/SCALE IT
	TAD OFFSET
	DISY 		/DISPLAY IT
	CLR
	ISZ CNT1 	/1000(8) PTS?
	JMP DISPLA
	ISZ CNT3 	/BOTH HALVES?
	SKP
	JMP ENDISP
	TAD M200 	/SECOND 1/2
	JMP DIS1
ENDISP,LAS 		/SHOULD WE STOP OR GO ON
	RAR
	SZL CLA 	/IS BIT 11 UP?
	JMP INDISP 	/YES, KEEP DISPLAYING
/
/
/
/FIRST STAGE INITIALIZATIONS
STAGE1,CLR
	TAD MU
	CIA
	DCA MMU
	IAC
	DCA L 		/L=1
	TAD N 		/N=#OF SAMPLES=1024(DECIMAL)=2000(OCTAL)
	HALF
	DCA S 		/S=(1/2)*N
	TAD S 		/FOR TRIG ROUTINES
	HALF
	DCA KPI2 	/ PI/2
	CMA
	TAD KPI2
	DCA QUADI 	/1ST QUADRANT PART
	CMA 		/-1
	TAD S
	DCA Q 		/Q=((1/2)*N)-1
/
/
/PASS 1&2 ARE ADDITIONS WITH NO MULTIPLICATIONS
/NO IMAGINARY PARTS IN PASS1 (0+0=0)
/ SMALL NUMBERS SO USE SINGLE PRECISION
/AND DON'T WORRY ABOUT OVERFLOWS
/
PASS1,	CLR
LOOP1,	TAD Q
	TAD REALPT
	DCA PTR1 	/POINTS TO X(Q)
	TAD REALPT
	TAD Q
	TAD S 		/N/2 NOW
	DCA PTR2 	/POINTS TO X(Q+N/2)
/
/ X(Q)=X(Q+N/2)+X(Q)
ADDER,	TAD I PTR1
	TAD I PTR2
	DCA TEMP
/
/ X(Q+N/2)=X(Q)-X(Q+N/2)
	TAD I PTR2
	CIA
	TAD I PTR1
	DCA I PTR2 	/SAVE IT
	TAD TEMP
	DCA I PTR1 	/SAVE IT
/
	TAD Q
	SMA SZA CLA 	/IS Q <OR=0?
	SKP
	JMP PASS2 	/NO, >0
	CMA 		/YES, -1
	TAD Q
	DCA Q 		/Q=Q-1
	JMP LOOP1
/
/
/
*377
/
/
/ PART 2
/
PASS2,	CLR
/
/DIVIDE PASS2 INTO LOWER AND UPPER
/ LOWER REDUCES TO:
/ XR(P)=XR(Q)
/ XI(P)=XR(P)
/ XR(Q)=XR(Q)
/ XI(Q)=-XR(P)
/ UPPER REDUCES TO:
/ XR(P)=XR(Q)-XR(P)
/ XR(Q)=XR(Q)+XR(P)
/ ALL XI=0
/
LOW2,	JMS SETMUP
	JMS SETSS
MOVE2L,TAD I PTR1
	DCA I PTR3 	/XI(P)=XR(P)
	TAD I PTR1
	CIA
	DCA I PTR4 	/XI(Q)=-XR(P)
	TAD I PTR2
	DCA I PTR1 	/XR(P)=XR(Q)
	CMA
	TAD P
	DCA P 		/P=P-1
	ISZ C 		/IS C=S?
	SKP 		/NOT YET
	JMP HIGH2 	/YES, DO UPPER
	JMS RSET 	/NO, DO SOME RESETTING
	JMP MOVE2L
/
HIGH2,	TAD S
	CIA
	TAD P
	DCA P 		/P=P-S
	JMS SETSS
MOVE2H,TAD I PTR1
	CIA
	TAD I PTR2
	DCA TEMP 	/XR(Q)-XR(P)
	TAD I PTR1
	TAD I PTR2
	DCA I PTR2 	/XR(Q)=XR(P)+XR(Q)
	TAD TEMP
	DCA I PTR1 	/XR(P)=XR(Q)-XR(P)
	CMA
	TAD P
	DCA P 		/P=P-1
	ISZ C 		/IS C=S?
	SKP 		/NOT YET
	JMP PASSES
	JMS RSET
	JMP MOVE2H
/
SETSS,	0 		/SET UP SUBSCRIPTS
	TAD S
	CIA
	DCA C 		/C=-S (C IS A COUNTER)
	TAD C
	TAD P
	DCA Q 		/Q=P-S
	TAD REALPT
	TAD P
	DCA PTR1 	/POINTS TO XR(P)
	TAD REALPT
	TAD Q
	DCA PTR2 	/POINTS TO XR(Q)
	TAD IMAGPT
	TAD P
	DCA PTR3 	/POINTS TO XI(P)
	TAD IMAGPT
	TAD Q
	DCA PTR4 	/POINTS TO XI(Q)
	JMP I SETSS
/
/

/
SETMUP,0 		/INITIALIZATIONS FOR PASS2 ON UP
	CLR
	TAD MMU
	TAD L
	SNA CLA 	/IS L=MU?
	JMP ORDER 	/...ALL BUT DONE...
/ /NO, DO INITIALIZATIONS
	ISZ L 		/L=L+1
	TAD S
	HALF
	DCA S 		/S=S/2
	CMA
	TAD N
	DCA P 		/P=N-1
	JMP I SETMUP
/
/
/
