SCCON Scientific Research Inc.

FFT Installation Guide and Example Software

A guide to assembling the 8087-based FFT subroutine and calling the routine from a high level program.

Description

The assembly language subroutine FFT5.ASM uses an 8087 to compute the Fast Fourier Transform. A test program FFT_TEST.C illustrates calling the FFT routine from within a C-program.

Source Code

Free software is provided 'as-is', with no warranties expressed or implied.


Using the FFT Routine Test Program

  1. Assemble the FFT5.ASM routine to create FFT5.OBJ, using:
  2.  C>  masm fft5.asm;
  3. Within a calling program such as FFT_TEST.C, declare the external assembly language routine as,
  4.  extern void FFT5( struct complex *vector, int N, int direction );
  5. Compile the test program, linking FFT5.OBJ, to create FFT_TEST.EXE, using:
  6.  C>  cl fft_test.c  fft5.obj
  7. Run the test program
  8.  C>  fft_text.exe


C-Language Test Program

From C-language, the above routine is declared in a prototype definition and called as a subroutine (both are highlighted in the listing below). A simple vector with eight points is sufficient to determine if the subroutine is working correctly.

/* FFT_TEST.C            R.Tervo                 16 FEB 97       */
/* ------------------------------------------------------------- */
/* Test the FFT routine, written using Microsoft C Version 5.1   */
/* Copyright (c) 1997 SCCON Scientific Research Inc.             */
/* For information, contact < tervo@sccon.ca >                   */
/* ------------------------------------------------------------- */
/* 1. Assemble the FFT routine to create fft5.OBJ, using:        */
/*    C>  masm fft5.asm;                                         */
/* 2. Compile the test program to create FFT_TEST.EXE, using:    */
/*    C>  cl fft_test.c  fft5.obj                                */
/* 3. Run the test program                                       */
/*    C>  fft_text.exe                                           */
/* ------------------------------------------------------------- */
/* This test program computes the discrete Fourier transform of  */
/* an 8-element vector consisting of an impulse at the origin.   */
/* The complex result should be eight real values, all 0.125     */
/* ------------------------------------------------------------- */

#include < stdio.h >

struct complex
{ double r;  /* real part */
  double i;  /* imag part */
} vec[8];

/* prototype definition */
extern void FFT5( struct complex *vector, int N, int direction );

main()
{ int x;

  for(x=0;x<8;x++)     /* Create input vector      */
  { vec[x].r = 0.000;  /* set real components zero */
    vec[x].i = 0.000;  /* set imag components zero */
  } vec[0].r = 1.000;  /* impulse at the origin    */

  FFT5( vec, 3, 0 );   /* compute FFT for 8 points */

  for(x=0;x<8;x++)     /* Display output vector   */
  printf("REAL[%i]= %2.3f,IMAG[%i]= %2.3f\n",x,vec[x].r,x,vec[x].i);

  return 0;
}

 Tech fax: +1-506-458-5958 Contact:
Back