/*The following Microsoft C 7.0 program should be linked with the assembly language library in Example 3. Combine the library with XLIB.LIB using the Microsoft LIB utility. The C program first initializes XLIB. Next, it creates a float array. A control block for SUMARRAY is then constructed and the call to SUMARRAY is executed. Finally, the condition code in the control block is inspected and results are printed.*/ #include #include extern long __far __pascal LINADR(void __far *ptr); extern void __far __pascal SUMARRAY(void __far *ptr); struct arraydata /*Structure for passing arguments to SUMARRAY*/ { long condcode; long n; long address; float sum; } ad; void main(void) { int i; long temp; float a[101]; temp = INITXLIB(); /*Initialize XLIB*/ if (temp != 0) /*See if an error occurred*/ { printf("Initialization Error: %lX\n",temp); return; } for(i = 0; i <= 100; i++) /*Initialize a[]*/ a[i] = i; ad.condcode = 0; /*Initialize the condition code*/ ad.n = 50; /*Will sum the first 50 elements in a[]*/ ad.address = LINADR(a); /*Compute and record linear address of a[]*/ SUMARRAY(&ad); /*Sum the array elements*/ if (ad.condcode != 0) /*See if an FPU error occurred*/ { printf("Error: %lX\n",ad.condcode); return; } printf("Sum: %f\n",ad.sum); /*The sum should be 1225*/ }