home *** CD-ROM | disk | FTP | other *** search
/ Der Mediaplex Sampler - Die 6 von Plex / 6_v_plex.zip / 6_v_plex / DISK5 / DOS_42 / XLIB30.ZIP / EXAMP3.C < prev    next >
C/C++ Source or Header  |  1993-12-19  |  2KB  |  50 lines

  1. /*The following Microsoft C 7.0 program should be linked with the assembly
  2. language library in Example 3.  Combine the library with XLIB.LIB using the
  3. Microsoft LIB utility.  The C program first initializes XLIB.  Next, it
  4. creates a float array.  A control block for SUMARRAY is then constructed
  5. and the call to SUMARRAY is executed.  Finally, the condition code in the
  6. control block is inspected and results are printed.*/
  7.  
  8. #include <stdio.h>
  9. #include <xlib.h>
  10.  
  11. extern long __far __pascal LINADR(void __far *ptr);
  12. extern void __far __pascal SUMARRAY(void __far *ptr);
  13.  
  14. struct arraydata            /*Structure for passing arguments to SUMARRAY*/
  15. {
  16.   long condcode;
  17.   long n;
  18.   long address;
  19.   float sum;
  20. } ad;
  21.  
  22. void main(void)
  23. {
  24.   int i;
  25.   long temp;
  26.   float a[101];
  27.  
  28.   temp = INITXLIB();        /*Initialize XLIB*/
  29.   if (temp != 0)            /*See if an error occurred*/
  30.   {
  31.     printf("Initialization Error:  %lX\n",temp);
  32.     return;
  33.   }
  34.  
  35.   for(i = 0; i <= 100; i++)   /*Initialize a[]*/
  36.     a[i] = i;
  37.  
  38.   ad.condcode = 0;            /*Initialize the condition code*/
  39.   ad.n = 50;                  /*Will sum the first 50 elements in a[]*/
  40.   ad.address = LINADR(a);     /*Compute and record linear address of a[]*/
  41.  
  42.   SUMARRAY(&ad);              /*Sum the array elements*/
  43.   if (ad.condcode != 0)       /*See if an FPU error occurred*/
  44.   {
  45.     printf("Error:  %lX\n",ad.condcode);
  46.     return;
  47.   }
  48.   printf("Sum:  %f\n",ad.sum);   /*The sum should be 1225*/
  49. }
  50.