home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
SIMTEL
/
CPMUG
/
CPMUG023.ARK
/
STOICFFT.STC
< prev
next >
Wrap
Text File
|
1984-04-29
|
3KB
|
97 lines
% ***************************************************************************
% ** COPYRIGHT (C) MASSACHUSETTS INSTITUTE OF TECHNOLOGY AND HARVARD **
% ** UNIVERSITY, BIOMEDICAL ENGINEERING CENTER 1977. ALL RIGHTS RESERVED. **
% ***************************************************************************
% FLOATING POINT FFT
% J. SACHS 1/28/77
RADIX @ OCTAL
% VARIABLES
0.0 'WR FCONSTANT % REAL PART OF W
0.0 'WI FCONSTANT % IMAGINARY PART OF W
0.0 'DELTA FCONSTANT % DELTA THETA
0 'IA VARIABLE % A INDEX
0 'IB VARIABLE % B INDEX
0 'ISTEP VARIABLE % STEP SIZE
0 'N VARIABLE % NUMBER OF POINTS
0 'LOG2N VARIABLE % LOG N BASE 2
0 'SENSE VARIABLE % SENSE OF FFT (-1 = FORWARD; 0 = REVERSE)
0 'CBUF VARIABLE % ADDRESS OF INPUT ARRAY
% RAISE 2 TO THE POWER AT TOP OF STACK
'2** CODE< D POP, 1 H LXI, E A MOV, A ORA, PUSH JZ,
. H DAD, E DCR, JNZ, PUSH JMP, >
% COMPLEX ARITHMETIC
'C+ : D2OVER F+ D2UNDER D2OVER F+ D2UNDER ;
'CEXP : FLOAT DELTA F* DDUP FCOS () WR F! FSIN () WI F! ;
'WC* : DOVER WR F* DOVER WI F* F- D2OVER WI F* D2OVER WR F* F+
D2UNDER D2UNDER ;
% LOAD COMPLEX NUMBER FROM ARRAY
'AC@ CODE< IA LHLD, . H DAD, H DAD, H DAD, XCHG, CBUF LHLD,
D DAD, M E MOV, H INX, M D MOV, H INX, M C MOV, H INX, M B MOV,
H INX, B PUSH, D PUSH, M E MOV, H INX, M D MOV, H INX, M C MOV,
H INX, M B MOV, B PUSH, D PUSH, NEXT JMP, >
'BC@ CODE< IB LHLD, JMP, >
% STORE COMPLEX NUMBER IN ARRAY
'AC! CODE< IA LHLD, . H DAD, H DAD, H DAD, XCHG, CBUF LHLD,
D DAD, 4 D LXI, D DAD,
D POP, E M MOV, H INX, D M MOV, H INX,
D POP, E M MOV, H INX, D M MOV, -7 D LXI, D DAD,
D POP, E M MOV, H INX, D M MOV, H INX,
D POP, E M MOV, H INX, D M MOV, NEXT JMP, >
'BC! CODE< IB LHLD, JMP, >
% FFT INNER CALCULATIONS
'SETUP CODE< H POP, IA SHLD, XCHG, ISTEP LHLD, D DAD,
IB SHLD, NEXT JMP, >
'BUTTERFLY : SETUP BC@ WC* DOVER FMINUS DOVER FMINUS AC@ C+ BC! AC@ C+ AC! ;
% BIT REVERSAL
'IABI CODE< IA LHLD, XCHG, LOG2N LDA, A C MOV, 0 H LXI,
. H DAD, D A MOV, RAR, A D MOV, E A MOV, RAR, A E MOV,
IFNC, H INX, THEN, C DCR, JNZ, IB SHLD, NEXT JMP, >
'BITREV : N @ 0 DO I IA ! IABI I IB @ LT IF AC@ BC@ AC! BC! THEN LOOP ;
% DIVIDE INPUT ARRAY BY SQRT(N)
'NORMALIZE : 1.0 N @ FLOAT FSQRT F/ () WR F!
N @ 0 DO I IA ! AC@ DSWAP WR F* DSWAP WR F* AC! LOOP ;
% ADDRESS LOG2N SENSE FFT
% ADDRESS IS START OF COMPLEX ARRAY
% LOG2N IS LOG BASE 2 OF NUMBER OF POINTS
% SENSE IS -1 FOR FORWARD TRANSFORM; 0 FOR REVERSE TRANSFORM
'FFT : SENSE ! DUP LOG2N ! 2** N ! CBUF !
BITREV NORMALIZE
LOG2N @ 0 DO
I 2** ISTEP ! PI ISTEP @ SENSE @ IF MINUS THEN FLOAT F/ () DELTA F!
ISTEP @ 0 DO
I CEXP N @ I DO
I BUTTERFLY
ISTEP @ 2* +LOOP
LOOP
LOOP
;
% DEFINE FORWARD AND REVERSE FFT'S
'RFFT : 0 FFT ;
'FFT : -1 FFT ;
RADIX !
;F
***EOF***