Listing 2

/*  complex hyperbolic sine routine intended to test
   argument passing and function returns only. This
   version passes a pointer to a global array and 
   returns a pointer to a similar array. */

#include <dos.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define BIOS_DATA_SEG  0x40
#define TIMER_DATA     0x6c
#define TICKS_PER_DAY  0x01800B0L
long getticks(void);
void csinh(double*);

double cplxarg[2], cplxrtn[2];

main()

{
   int ctr;
   long start, end;
   
   start = getticks();
   printf("\n BEGIN AT CLOCK = %ld", start);
   
   *cplxarg = 3.0;
   *(cplxarg + 1) = -2.0;
   
   for(ctr = 1; ctr <= 5000; ++ctr)
      csinh(cplxarg);
   
   end = getticks();
   
   printf("\n\n        REAL RESULT = %lG", *cplxrtn);
   printf("        IMAG RESULT = %lG", *(cplxrtn + 1));
   
   printf("\n    END AT CLOCK = %ld", end);
   printf("\n\n   ELAPSED TICKS = %ld", end - start);
}

void csinh(double *arg)

{
   *cplxrtn = cos(*(arg + 1)) * sinh(*arg);
   *(cplxrtn + 1) = sin(*(arg + 1)) *cosh(*arg);
}