Home » Recent acquisitions » Acorn ADFS disks » adfs_ArchimedesWorld_199201.adf » January92 » !AWJan92/Goodies/ProgTheARM/FFT3

!AWJan92/Goodies/ProgTheARM/FFT3

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Recent acquisitions » Acorn ADFS disks » adfs_ArchimedesWorld_199201.adf » January92
Filename: !AWJan92/Goodies/ProgTheARM/FFT3
Read OK:
File size: 076B bytes
Load address: 0000
Exec address: 0000
File contents
   10REM > FFT3
   20
   30MODE 12
   40
   50N%=128
   60
   70n2%=2*N%
   80
   90DIM data(n2%)
   91J=0
  100REPEAT
  110J+=25
  120CLS
  130PRINTJ
  140
  150GCOL7
  160
  170FOR I%=0TO N%-1
  180  ii%=2*I%+1
  190  data(ii%)   = SINRAD(I%*J)
  200  data(ii%+1) = 0
  210  MOVE 4*I%,512
  220  DRAW 4*I%,512+256*data(ii%)
  230NEXT
  240
  250PROCfour1(N%,1)
  260
  270GCOL1
  280
  290FOR I%=0 TO (N%-1) DIV 2
  300  ii%=2*I%+1
  310  MOVE 8*I%,0
  320  DRAW 8*I%,8*ABS(data(ii%))
  330NEXT
  340
  560UNTILGET=13
  570END
  580
  590
  600REM data() accessed by refernece
  610DEFPROCfour1(nn%,isign%)
  620
  630LOCALii%,jj%,n%,mmax%,m%,j%,istep%,i%
  640LOCALwtemp,wr,wpr,wpi,wi,theta
  650LOCALtempr,tempi,wrs,wis
  660
  670LOCALs
  680
  690n%=2*nn%
  700j%=1
  710REM This is the bit-reversal section of the routine
  720FOR ii%=1 TO nn%
  730  i%=2*ii%-1
  740  IF j% > i% THEN
  750    REM Swap the real and imarinary parts of the two
  760    tempr      = data(j%) : tempi      = data(j%+1)
  770    data(j%)   = data(i%) : data(j%+1) = data(i%+1)
  780    data(i%)   = tempr    : data(i%+1) = tempi
  790  ENDIF
  800  m% = n% DIV 2
  810  WHILE (m%>=2) AND (j%>m%)
  820    j% = j% - m%
  830    m% = m% DIV 2
  840  ENDWHILE
  850  j% = j% + m%
  860NEXT
  870
  880mmax% = 2
  890
  900REM Now the Danielson-Lanczos recurrence
  910
  920WHILE n% > mmax%
  930  istep% = 2*mmax%
  940  theta  = 2 * PI / (isign%*mmax%)
  950
  960        s=SIN(0.5*theta)
  970  wpr    = -2.0 * s*s
  980  wpi    = SIN(theta)
  990
 1000  wr = 1.0
 1010  wi = 0.0
 1020  FOR ii% = 1 TO mmax% DIV 2
 1030    m% = 2*ii%-1
 1040    wrs = wr
 1050    wis = wi
 1060    FOR jj%=0 TO (n%-m%) DIV istep%
 1070      i% = m% + jj%*istep%
 1080      j% = i%+mmax%
 1090      tempr = wrs*data(j%)   - wis*data(j%+1)
 1100      tempi = wrs*data(j%+1) + wis*data(j%)
 1110      data(j%)   = data(i%)   - tempr
 1120      data(j%+1) = data(i%+1) - tempi
 1130      data(i%)   = data(i%)   + tempr
 1140      data(i%+1) = data(i%+1) + tempi
 1150    NEXT
 1160    wtemp = wr
 1170    wr = wr*wpr -    wi*wpi + wr
 1180    wi = wi*wpr + wtemp*wpi  +wi
 1190  NEXT
 1200  mmax% = istep%
 1210ENDWHILE
 1220ENDPROC
 1230
 1240
 1250
 1260
 1270
 1280
 1290
 1300
 1310
 1320
 1330
 1340
 1350
 1360
 1370
 1380

� > FFT3

� 12
(
2
N%=128
<
Fn2%=2*N%
P
Z� data(n2%)
[J=0
d�
n	J+=25
x�
��J
�
��7
�
�� I%=0� N%-1
�  ii%=2*I%+1
�  data(ii%)   = ��(I%*J)
�  data(ii%+1) = 0
�  � 4*I%,512
�  � 4*I%,512+256*data(ii%)
��
�
��four1(N%,1)

�1

"� I%=0 � (N%-1) � 2
,  ii%=2*I%+1
6  � 8*I%,0
@  � 8*I%,8*�(data(ii%))
J�
T
0	��=13
:�
D
N
X"� data() accessed by refernece
b��four1(nn%,isign%)
l
v%�ii%,jj%,n%,mmax%,m%,j%,istep%,i%
��wtemp,wr,wpr,wpi,wi,theta
��tempr,tempi,wrs,wis
�
��s
�
�n%=2*nn%
�j%=1
�5� This is the bit-reversal section of the routine
�� ii%=1 � nn%
�  i%=2*ii%-1
�  � j% > i% �
�6    � Swap the real and imarinary parts of the two
�7    tempr      = data(j%) : tempi      = data(j%+1)
7    data(j%)   = data(i%) : data(j%+1) = data(i%+1)
2    data(i%)   = tempr    : data(i%+1) = tempi
  �
   m% = n% � 2
*  ȕ (m%>=2) � (j%>m%)
4    j% = j% - m%
>    m% = m% � 2
H  �
R  j% = j% + m%
\�
f
p
mmax% = 2
z
�*� Now the Danielson-Lanczos recurrence
�
�ȕ n% > mmax%
�  istep% = 2*mmax%
�%  theta  = 2 * � / (isign%*mmax%)
�
�        s=�(0.5*theta)
�  wpr    = -2.0 * s*s
�  wpi    = �(theta)
�
�  wr = 1.0
�  wi = 0.0
�  � ii% = 1 � mmax% � 2
    m% = 2*ii%-1
    wrs = wr
    wis = wi
$"    � jj%=0 � (n%-m%) � istep%
.      i% = m% + jj%*istep%
8      j% = i%+mmax%
B1      tempr = wrs*data(j%)   - wis*data(j%+1)
L/      tempi = wrs*data(j%+1) + wis*data(j%)
V)      data(j%)   = data(i%)   - tempr
`)      data(j%+1) = data(i%+1) - tempi
j)      data(i%)   = data(i%)   + tempr
t)      data(i%+1) = data(i%+1) + tempi
~	    �
�    wtemp = wr
�$    wr = wr*wpr -    wi*wpi + wr
�$    wi = wi*wpr + wtemp*wpi  +wi
�  �
�  mmax% = istep%
��
��
�
�
�
�
�





(
2
<
F
P
Z
d
�
00000000  0d 00 0a 0c f4 20 3e 20  46 46 54 33 0d 00 14 04  |..... > FFT3....|
00000010  0d 00 1e 08 eb 20 31 32  0d 00 28 04 0d 00 32 0a  |..... 12..(...2.|
00000020  4e 25 3d 31 32 38 0d 00  3c 04 0d 00 46 0c 6e 32  |N%=128..<...F.n2|
00000030  25 3d 32 2a 4e 25 0d 00  50 04 0d 00 5a 0f de 20  |%=2*N%..P...Z.. |
00000040  64 61 74 61 28 6e 32 25  29 0d 00 5b 07 4a 3d 30  |data(n2%)..[.J=0|
00000050  0d 00 64 05 f5 0d 00 6e  09 4a 2b 3d 32 35 0d 00  |..d....n.J+=25..|
00000060  78 05 db 0d 00 82 06 f1  4a 0d 00 8c 04 0d 00 96  |x.......J.......|
00000070  06 e6 37 0d 00 a0 04 0d  00 aa 10 e3 20 49 25 3d  |..7......... I%=|
00000080  30 b8 20 4e 25 2d 31 0d  00 b4 10 20 20 69 69 25  |0. N%-1....  ii%|
00000090  3d 32 2a 49 25 2b 31 0d  00 be 1c 20 20 64 61 74  |=2*I%+1....  dat|
000000a0  61 28 69 69 25 29 20 20  20 3d 20 b5 b2 28 49 25  |a(ii%)   = ..(I%|
000000b0  2a 4a 29 0d 00 c8 15 20  20 64 61 74 61 28 69 69  |*J)....  data(ii|
000000c0  25 2b 31 29 20 3d 20 30  0d 00 d2 10 20 20 ec 20  |%+1) = 0....  . |
000000d0  34 2a 49 25 2c 35 31 32  0d 00 dc 1e 20 20 df 20  |4*I%,512....  . |
000000e0  34 2a 49 25 2c 35 31 32  2b 32 35 36 2a 64 61 74  |4*I%,512+256*dat|
000000f0  61 28 69 69 25 29 0d 00  e6 05 ed 0d 00 f0 04 0d  |a(ii%)..........|
00000100  00 fa 10 f2 66 6f 75 72  31 28 4e 25 2c 31 29 0d  |....four1(N%,1).|
00000110  01 04 04 0d 01 0e 06 e6  31 0d 01 18 04 0d 01 22  |........1......"|
00000120  17 e3 20 49 25 3d 30 20  b8 20 28 4e 25 2d 31 29  |.. I%=0 . (N%-1)|
00000130  20 81 20 32 0d 01 2c 10  20 20 69 69 25 3d 32 2a  | . 2..,.  ii%=2*|
00000140  49 25 2b 31 0d 01 36 0e  20 20 ec 20 38 2a 49 25  |I%+1..6.  . 8*I%|
00000150  2c 30 0d 01 40 1b 20 20  df 20 38 2a 49 25 2c 38  |,0..@.  . 8*I%,8|
00000160  2a 94 28 64 61 74 61 28  69 69 25 29 29 0d 01 4a  |*.(data(ii%))..J|
00000170  05 ed 0d 01 54 04 0d 02  30 09 fd a5 3d 31 33 0d  |....T...0...=13.|
00000180  02 3a 05 e0 0d 02 44 04  0d 02 4e 04 0d 02 58 22  |.:....D...N...X"|
00000190  f4 20 64 61 74 61 28 29  20 61 63 63 65 73 73 65  |. data() accesse|
000001a0  64 20 62 79 20 72 65 66  65 72 6e 65 63 65 0d 02  |d by refernece..|
000001b0  62 17 dd f2 66 6f 75 72  31 28 6e 6e 25 2c 69 73  |b...four1(nn%,is|
000001c0  69 67 6e 25 29 0d 02 6c  04 0d 02 76 25 ea 69 69  |ign%)..l...v%.ii|
000001d0  25 2c 6a 6a 25 2c 6e 25  2c 6d 6d 61 78 25 2c 6d  |%,jj%,n%,mmax%,m|
000001e0  25 2c 6a 25 2c 69 73 74  65 70 25 2c 69 25 0d 02  |%,j%,istep%,i%..|
000001f0  80 1e ea 77 74 65 6d 70  2c 77 72 2c 77 70 72 2c  |...wtemp,wr,wpr,|
00000200  77 70 69 2c 77 69 2c 74  68 65 74 61 0d 02 8a 18  |wpi,wi,theta....|
00000210  ea 74 65 6d 70 72 2c 74  65 6d 70 69 2c 77 72 73  |.tempr,tempi,wrs|
00000220  2c 77 69 73 0d 02 94 04  0d 02 9e 06 ea 73 0d 02  |,wis.........s..|
00000230  a8 04 0d 02 b2 0c 6e 25  3d 32 2a 6e 6e 25 0d 02  |......n%=2*nn%..|
00000240  bc 08 6a 25 3d 31 0d 02  c6 35 f4 20 54 68 69 73  |..j%=1...5. This|
00000250  20 69 73 20 74 68 65 20  62 69 74 2d 72 65 76 65  | is the bit-reve|
00000260  72 73 61 6c 20 73 65 63  74 69 6f 6e 20 6f 66 20  |rsal section of |
00000270  74 68 65 20 72 6f 75 74  69 6e 65 0d 02 d0 11 e3  |the routine.....|
00000280  20 69 69 25 3d 31 20 b8  20 6e 6e 25 0d 02 da 10  | ii%=1 . nn%....|
00000290  20 20 69 25 3d 32 2a 69  69 25 2d 31 0d 02 e4 11  |  i%=2*ii%-1....|
000002a0  20 20 e7 20 6a 25 20 3e  20 69 25 20 8c 0d 02 ee  |  . j% > i% ....|
000002b0  36 20 20 20 20 f4 20 53  77 61 70 20 74 68 65 20  |6    . Swap the |
000002c0  72 65 61 6c 20 61 6e 64  20 69 6d 61 72 69 6e 61  |real and imarina|
000002d0  72 79 20 70 61 72 74 73  20 6f 66 20 74 68 65 20  |ry parts of the |
000002e0  74 77 6f 0d 02 f8 37 20  20 20 20 74 65 6d 70 72  |two...7    tempr|
000002f0  20 20 20 20 20 20 3d 20  64 61 74 61 28 6a 25 29  |      = data(j%)|
00000300  20 3a 20 74 65 6d 70 69  20 20 20 20 20 20 3d 20  | : tempi      = |
00000310  64 61 74 61 28 6a 25 2b  31 29 0d 03 02 37 20 20  |data(j%+1)...7  |
00000320  20 20 64 61 74 61 28 6a  25 29 20 20 20 3d 20 64  |  data(j%)   = d|
00000330  61 74 61 28 69 25 29 20  3a 20 64 61 74 61 28 6a  |ata(i%) : data(j|
00000340  25 2b 31 29 20 3d 20 64  61 74 61 28 69 25 2b 31  |%+1) = data(i%+1|
00000350  29 0d 03 0c 32 20 20 20  20 64 61 74 61 28 69 25  |)...2    data(i%|
00000360  29 20 20 20 3d 20 74 65  6d 70 72 20 20 20 20 3a  |)   = tempr    :|
00000370  20 64 61 74 61 28 69 25  2b 31 29 20 3d 20 74 65  | data(i%+1) = te|
00000380  6d 70 69 0d 03 16 07 20  20 cd 0d 03 20 11 20 20  |mpi....  ... .  |
00000390  6d 25 20 3d 20 6e 25 20  81 20 32 0d 03 2a 1a 20  |m% = n% . 2..*. |
000003a0  20 c8 95 20 28 6d 25 3e  3d 32 29 20 80 20 28 6a  | .. (m%>=2) . (j|
000003b0  25 3e 6d 25 29 0d 03 34  14 20 20 20 20 6a 25 20  |%>m%)..4.    j% |
000003c0  3d 20 6a 25 20 2d 20 6d  25 0d 03 3e 13 20 20 20  |= j% - m%..>.   |
000003d0  20 6d 25 20 3d 20 6d 25  20 81 20 32 0d 03 48 07  | m% = m% . 2..H.|
000003e0  20 20 ce 0d 03 52 12 20  20 6a 25 20 3d 20 6a 25  |  ...R.  j% = j%|
000003f0  20 2b 20 6d 25 0d 03 5c  05 ed 0d 03 66 04 0d 03  | + m%..\....f...|
00000400  70 0d 6d 6d 61 78 25 20  3d 20 32 0d 03 7a 04 0d  |p.mmax% = 2..z..|
00000410  03 84 2a f4 20 4e 6f 77  20 74 68 65 20 44 61 6e  |..*. Now the Dan|
00000420  69 65 6c 73 6f 6e 2d 4c  61 6e 63 7a 6f 73 20 72  |ielson-Lanczos r|
00000430  65 63 75 72 72 65 6e 63  65 0d 03 8e 04 0d 03 98  |ecurrence.......|
00000440  11 c8 95 20 6e 25 20 3e  20 6d 6d 61 78 25 0d 03  |... n% > mmax%..|
00000450  a2 16 20 20 69 73 74 65  70 25 20 3d 20 32 2a 6d  |..  istep% = 2*m|
00000460  6d 61 78 25 0d 03 ac 25  20 20 74 68 65 74 61 20  |max%...%  theta |
00000470  20 3d 20 32 20 2a 20 af  20 2f 20 28 69 73 69 67  | = 2 * . / (isig|
00000480  6e 25 2a 6d 6d 61 78 25  29 0d 03 b6 04 0d 03 c0  |n%*mmax%).......|
00000490  1a 20 20 20 20 20 20 20  20 73 3d b5 28 30 2e 35  |.        s=.(0.5|
000004a0  2a 74 68 65 74 61 29 0d  03 ca 19 20 20 77 70 72  |*theta)....  wpr|
000004b0  20 20 20 20 3d 20 2d 32  2e 30 20 2a 20 73 2a 73  |    = -2.0 * s*s|
000004c0  0d 03 d4 17 20 20 77 70  69 20 20 20 20 3d 20 b5  |....  wpi    = .|
000004d0  28 74 68 65 74 61 29 0d  03 de 04 0d 03 e8 0e 20  |(theta)........ |
000004e0  20 77 72 20 3d 20 31 2e  30 0d 03 f2 0e 20 20 77  | wr = 1.0....  w|
000004f0  69 20 3d 20 30 2e 30 0d  03 fc 1b 20 20 e3 20 69  |i = 0.0....  . i|
00000500  69 25 20 3d 20 31 20 b8  20 6d 6d 61 78 25 20 81  |i% = 1 . mmax% .|
00000510  20 32 0d 04 06 14 20 20  20 20 6d 25 20 3d 20 32  | 2....    m% = 2|
00000520  2a 69 69 25 2d 31 0d 04  10 10 20 20 20 20 77 72  |*ii%-1....    wr|
00000530  73 20 3d 20 77 72 0d 04  1a 10 20 20 20 20 77 69  |s = wr....    wi|
00000540  73 20 3d 20 77 69 0d 04  24 22 20 20 20 20 e3 20  |s = wi..$"    . |
00000550  6a 6a 25 3d 30 20 b8 20  28 6e 25 2d 6d 25 29 20  |jj%=0 . (n%-m%) |
00000560  81 20 69 73 74 65 70 25  0d 04 2e 1e 20 20 20 20  |. istep%....    |
00000570  20 20 69 25 20 3d 20 6d  25 20 2b 20 6a 6a 25 2a  |  i% = m% + jj%*|
00000580  69 73 74 65 70 25 0d 04  38 17 20 20 20 20 20 20  |istep%..8.      |
00000590  6a 25 20 3d 20 69 25 2b  6d 6d 61 78 25 0d 04 42  |j% = i%+mmax%..B|
000005a0  31 20 20 20 20 20 20 74  65 6d 70 72 20 3d 20 77  |1      tempr = w|
000005b0  72 73 2a 64 61 74 61 28  6a 25 29 20 20 20 2d 20  |rs*data(j%)   - |
000005c0  77 69 73 2a 64 61 74 61  28 6a 25 2b 31 29 0d 04  |wis*data(j%+1)..|
000005d0  4c 2f 20 20 20 20 20 20  74 65 6d 70 69 20 3d 20  |L/      tempi = |
000005e0  77 72 73 2a 64 61 74 61  28 6a 25 2b 31 29 20 2b  |wrs*data(j%+1) +|
000005f0  20 77 69 73 2a 64 61 74  61 28 6a 25 29 0d 04 56  | wis*data(j%)..V|
00000600  29 20 20 20 20 20 20 64  61 74 61 28 6a 25 29 20  |)      data(j%) |
00000610  20 20 3d 20 64 61 74 61  28 69 25 29 20 20 20 2d  |  = data(i%)   -|
00000620  20 74 65 6d 70 72 0d 04  60 29 20 20 20 20 20 20  | tempr..`)      |
00000630  64 61 74 61 28 6a 25 2b  31 29 20 3d 20 64 61 74  |data(j%+1) = dat|
00000640  61 28 69 25 2b 31 29 20  2d 20 74 65 6d 70 69 0d  |a(i%+1) - tempi.|
00000650  04 6a 29 20 20 20 20 20  20 64 61 74 61 28 69 25  |.j)      data(i%|
00000660  29 20 20 20 3d 20 64 61  74 61 28 69 25 29 20 20  |)   = data(i%)  |
00000670  20 2b 20 74 65 6d 70 72  0d 04 74 29 20 20 20 20  | + tempr..t)    |
00000680  20 20 64 61 74 61 28 69  25 2b 31 29 20 3d 20 64  |  data(i%+1) = d|
00000690  61 74 61 28 69 25 2b 31  29 20 2b 20 74 65 6d 70  |ata(i%+1) + temp|
000006a0  69 0d 04 7e 09 20 20 20  20 ed 0d 04 88 12 20 20  |i..~.    .....  |
000006b0  20 20 77 74 65 6d 70 20  3d 20 77 72 0d 04 92 24  |  wtemp = wr...$|
000006c0  20 20 20 20 77 72 20 3d  20 77 72 2a 77 70 72 20  |    wr = wr*wpr |
000006d0  2d 20 20 20 20 77 69 2a  77 70 69 20 2b 20 77 72  |-    wi*wpi + wr|
000006e0  0d 04 9c 24 20 20 20 20  77 69 20 3d 20 77 69 2a  |...$    wi = wi*|
000006f0  77 70 72 20 2b 20 77 74  65 6d 70 2a 77 70 69 20  |wpr + wtemp*wpi |
00000700  20 2b 77 69 0d 04 a6 07  20 20 ed 0d 04 b0 14 20  | +wi....  ..... |
00000710  20 6d 6d 61 78 25 20 3d  20 69 73 74 65 70 25 0d  | mmax% = istep%.|
00000720  04 ba 05 ce 0d 04 c4 05  e1 0d 04 ce 04 0d 04 d8  |................|
00000730  04 0d 04 e2 04 0d 04 ec  04 0d 04 f6 04 0d 05 00  |................|
00000740  04 0d 05 0a 04 0d 05 14  04 0d 05 1e 04 0d 05 28  |...............(|
00000750  04 0d 05 32 04 0d 05 3c  04 0d 05 46 04 0d 05 50  |...2...<...F...P|
00000760  04 0d 05 5a 04 0d 05 64  04 0d ff                 |...Z...d...|
0000076b