home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / dsp / dspgroup / m56000_1.arc / DITFFT.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-03-14  |  2.4 KB  |  90 lines

  1. ditfft    macro    points,passes,data,twiddle
  2. ;
  3. ; Radix 2 Decimation in Time In-Place Fast Fourier Transform Routine
  4. ;
  5. ;    Complex input and output data
  6. ;        Real data in X memory
  7. ;        Imaginary data in Y memory
  8. ;    Normally ordered input data
  9. ;    Bit reversed output data
  10. ;    Twiddle factors lookup table
  11. ;        Cosine value in X memory
  12. ;        -Sine value in Y memory
  13. ;
  14. ; Macro Call - ditfft points,passes,data,twiddle
  15. ;
  16. ;    points     number of points (4-32768, power of 2)
  17. ;    passes     number of fft passes (log2 points)
  18. ;    data       start of data buffer
  19. ;    twiddle    start of sine/cosine table
  20. ;
  21. ; Alters Data ALU Registers
  22. ;    x1    x0    y1    y0
  23. ;    a2    a1    a0    a
  24. ;    b2    b1    b0    b
  25. ;
  26. ; Alters Address Registers
  27. ;    r0    n0    m0
  28. ;    r1    n1    m1
  29. ;        n2
  30. ;
  31. ;    r4    n4    m4
  32. ;    r5    n5    m5
  33. ;    r6    n6    m6
  34. ;
  35. ; Alters Program Control Registers
  36. ;    pc    sr
  37. ;
  38. ; Uses 6 locations on System Stack
  39. ;
  40. ; Authors - Kevin Kloker and Garth Hillman
  41. ; Latest Revision - Jan. 20, 1986
  42. ;
  43.     page
  44.     move     #points,n0    ;initialize butterflies per group
  45.     move    #1,n2        ;initialize groups per pass
  46.     move    #points/4,n6    ;initialize twiddle offset
  47.     move    #-1,m0        ;initialize address modifiers
  48.     move    m0,m1        ;for linear addressing
  49.     move    m0,m4
  50.     move    m0,m5
  51.     move    #0,m6        ;initialize twiddle factor address modifier
  52.                 ;for reverse carry (bit reversed) addressing
  53. ;
  54. ; Perform all FFT passes with triple nested DO loop
  55. ;
  56.     do    #passes,_end_pass
  57.     move    n0,a1        ;divide butterflies per group by two
  58.     lsr    a    #data,r0    ;and initialize A input pointer
  59.     move    a1,n0        ;update butterflies per group
  60.     move    r0,r4        ;initialize A output pointer
  61.     lua    (r0)+n0,r1    ;initialize B input pointer
  62.     lua    (r1)-,r5    ;initialize B output pointer
  63.     move    #twiddle,r6    ;initialize twiddle factor pointer
  64.     move    n0,n1        ;initialize pointer offsets
  65.     move    n0,n4
  66.     move    n0,n5
  67.  
  68.     do    n2,_end_grp
  69.     move    x:(r1),x1    y:(r6),y0    ;lookup -sine value
  70.     move    x:(r5),a    y:(r0),b    ;dummy load of a
  71.     move    x:(r6)+n6,x0        ;lookup cosine value
  72.  
  73.  
  74.     do    n0,_end_bfy
  75.     mac    x1,y0,b                y:(r1)+,y1    ;Radix 2 DIT butterfly kernel
  76.     macr    x0,y1,b        a,x:(r5)+    y:(r0),a    ;with constant twiddle factor
  77.     subl    b,a        x:(r0),b    b,y:(r4)
  78.     mac    x1,x0,b        x:(r0)+,a    a,y:(r5)
  79.     macr    -y1,y0,b    x:(r1),x1
  80.     subl    b,a        b,x:(r4)+    y:(r0),b
  81. _end_bfy
  82.     move    a,x:(r5)+n5    y:(r1)+n1,y1    ;dummy load of x1 and y1
  83.     move    x:(r0)+n0,x1    y:(r4)+n4,y1
  84. _end_grp
  85.     move    n2,a1
  86.     lsl    a        ;multiply groups per pass by two
  87.     move    a1,n2        ;update groups per pass
  88. _end_pass
  89.     endm
  90.