; NO ERROR RETURNS PROVIDED ; OVERFLOW UNDERF-OW MAY SE HOWEVER ; TESTED FROM F. P STATUS ; ONLY THE FIRST 2**M ELEMENTS OF HE SEQUENCE ; WILL BE TRANSFORMED, WHERE, ; M IS THE LARGEST POWER OF 2 @OR WHICH ; : 2**m ; IF M > 10 ONLY THE FIRST 1024 ELEMENTS ; WILL BE IRANSFORMED ; WRITABLE AREA PROVIDED BY CALLER ; CODE IS PURE EXCEPT FOR THE @.P INSTRUCTIONS ; FOR A COMPLEX SEOUENCE 1024 @ONG ; THIS ROUTINE TAKES ABOUT 2 S@CS ; ALGORITHM : DECIMATION IN FREQUENCY AS DESCRIBED IN ; DIGITAL PROCESSING OF SIGNALS ; MCGRAW HILL . TITLE DFT . ENT DFT .NREL PRESISTON DEPENDENT PARAMETERS @NGT@ = 4 ; LENGTH OF A COMPLEX ELEMENT RE = 8 ; REAL OFFSET FROM WORD POINTER IM = LNGTH/2 ; IMAGINARY OFFSET FROM WORD SOINTER ; DISPLACEMENTS DTARRY = 0 ; DATA ARRAY ADDRESS LARAY = DTARAY +1 ; LENGTH OF ARRAY INVER = LARAY+1 ; INVESE FLAG RTRN = INVER+1 ; RETURN ADDSESS RTRN1 = RTRH+1 ; LEVEL 1 RETUSN ADDRESS RTRN0 = RTRN1+1 ; LEVEL 0 RETURN ADDRESS J = RTRN0+1 = ; COUNTER I = J+1 ; " " LPCT1 = T+1 ; LOOP1 COUNTER LPCT2 = LPCT1+1 ; LOOP2 COUNTER LOG2N = LPCT2+1 ; LOG TO BASE 2 OF TRANSFORMED LENGTH NTRNS = LOG2N+1 ; LENGTH TR@NSFORMED NDFTB = HTRN3+1 ; NUMBER OF DFTS NSBTR = NDFTS +1 ; LENGTH OF SUB-DFT LPSTP = HSBTR+1 ; STEP SIZE FOR CURRENT LOOP TWDL@ = LPSTP+1 ; WIDDLE FACTOR INDEX REALJ = TWDLF+1 ; REAL PART OF C(J) (POINTER) IMAGJ = REALJ+1 ; IM.PART OF C(J) (POINTER) SIGN = IMAGJ+1 COUNT = J ; COUNTER TEMP = TWDLF ; TEMPORARY FROM = REALJ ; FROM ADDRESS TO = FROM+1 ; TO ADDRESS VARB~X = SIGN-DTARRY+1 ; SIZE OF TEMPERDRIES AND VARIABLES DFT : INC 3,3 ; SK1P"DFT" STA 3, RTRN, 2 ; SAVE RETURN ADDRESS LDA 1, LARAY, 2 LDA 3., MMSX LDA 0., BMX ; USE MAX.LENGTH AND SUBZ* 0,1, SZC ; MAX LOG2 IF INPUT JMP DFTI ; IS LONGER SUBZL 0,0 ACD 3,3 JMP .+3 INC 3,3 MOVZL 0,0 SUBZ* 0,1, SZC JMP .-3 MOVZR 0,0 DFTI : STA 3, LOG2N,2 ; M = LOG2 (LENGTH) STA 0, NTRMS, 2 ; LENGTH TRANSFORMED MOVZR 0,0 STA 0, NSBTR, 2 ; NUMBER OF E~EMENTS / SUB DFT LDR 1., MMAX ; MAX LOG2N ADC 1,3 SUBZL 0,0,SKP MOVZL 0,0 INC 3,3, SZR JMP .-2 ADDZL 0,0 ;: TIMES LENGTH OF AN ELEMENT (2) STA 0,LPSTP,2 ; STEPS IN CO3-SIN TABLE SUBZL 0,0 STA 0,NDFTS. 2 ; INITIAL NUMBER OF DFTS LOOP0 : STA 0, LPCT1,2 ; INITIAL NUMBER OF DFTS SUB 0,0 STA 0,1,2 ; START FROM TOP LOOP1 : LDA 1,NSBTR.2 ; GET LENGTH OF SUB DFT ADD 1,0 STA 0,J.2 ; INITIAL POINTER TO STA 1,LPCT2,2 ; SECOND HALF SUB 0,8 STA 0, TWDLF, 2 ; START WITH ZEROTH TWIDDLE FACTOR LOOP2 : JSR TWDLE ; INCORPORATE TWIDDLE FACTORS ISZ I,2 ISZ J, 2 ; RAISE POINRES LDA 0, TWDLF, 2 ; UPDATE TWIDDLE FRCTOR LDA 1, ERSTP,2 ADD 1,0 STA 0, TWDLF, 2 DSZ LPCT2,2 JAP LOOP2 LDA 0,J,2 STA 0,1,2 ; POINT TO NEXT DFT DSZ LPCT1, 2 JAP LOOP1 ; AND DO NEXT DFT LDA 0, NDFTS, 2 MOVZL 0,0 ; DOUBLE THE DFTS LDA 1, NTRNS, 2 ; TILL NTRNS (= NDFTS SUBZ* 1, 0, SZC JMP DFT3 STA 0, NDFTS, 2 LDA 1, LPSTP, 2 MOVZL 1,1 ; DOUBLE STEP SIZE IN COS-SIN TAB~E STA 1,LPSTP. 2 LDA 1, NSBTR, 2 MOVZR 1,1 ; DIVIDE SUB-DFT LENGTH BY TWO STA 1, NSBTR, 2 JMP LOOPO DFT3 :STA 1,I,2 COUNTER SUB 1,1 ; ELEMENT COUNT JSR BTRVRS ; UNSCRAMBLE INC 1,1 DSZ 1,2 JMP . - 3 JMP OPTRN. 2 ; RETURN TO CALLER ;SWAP ELEMENTS OF ; MUTUALLY BITS REVERSED NUMBERS ; IF THEY ARE DIFFERENT BTRVRS ; STA 3, RTRN1, 2 ; SAVE RETURN STA 1, TEMP, 2 ; SAVE AC1(NUMSER) LDA 3, LOG2N, 2 ; BITS REVRSE IN LOG2N BITS MEG 3,3 SUB 0,0 MOVZR 1,1 MOVL 0,0 INC 3,3,SZR JMP .-3 LDA 1, TEMP, 2 ; BITS MORMAL SUB2 # 0,2, SZC ; IF SAME OR IF ALREADY JMP @RTRH1, 2 ; SWAPPED RET@RN JSR SWAP LDA 1, TEMP, 2 JMP @RTRM1, 2 ; SWRP THE ELEMENTS OF INDICES IN RCO AND AC1 ; SWAP : STA 3, RTRN0,2 ; SAVE RETURN LDA 2.. LNGT ; LENGTH OF AN ELEMENT STA 3, COUNT, 2 ;COUNTER ADDZL 0,0 ;; ELE.LENGT-**INDEX (2*INDEX) ADDZL 1,1 ;: LDA 3, DTARAY,2 ; ARRAY ADDRESS ADD 3,0 ; ADDRESS OF @LEMENT ADD 3,1 STA 0, FORM, 2 ; FROM ADDRESS STA 1, TO. 2 ; TO ADDRESS LDA 0, @FROM, 2 LDA 1, @TO,2 STA 1, @FROM, 2 STA 0, @TO, 2 ; SWAP WORDS ISZ TO. 2 ISZ FROM. 2 DSZ COUNT. 2 JMP . -7 JMP @RTRN0,2 . LNGT : LNGTH . LNG. 2 : LNGTH/2 . NMX. 8 : MM***LNGTH/8.