home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 13 / MA_Cover_13.bin / source / c / apl / ax.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-11-23  |  758 b   |  38 lines

  1. /*
  2.  *    Floating-point initialization and trap service
  3.  *
  4.  *    On the PDP-11's the code in "ax.pdp.s" is preferred
  5.  *    since it enables the FPP for all floating exception
  6.  *    traps and fishes out the cause of an exception from
  7.  *    the FPP error register.
  8.  */
  9.  
  10. #include <signal.h>
  11.  
  12. char *fpelist[] = {
  13.     "floating exception",
  14.     "integer overflow",
  15.     "integer divide by zero",
  16.     "floating overflow",
  17.     "floating divide by zero",
  18.     "floating underflow",
  19.     "decimal overflow",
  20.     "subscript range",
  21.     "floating overflow",
  22.     "floating divide by zero",
  23.     "floating underflow"
  24. };
  25.  
  26. fpe(signo, param)
  27. unsigned param;
  28. {
  29.     signal(SIGFPE, fpe);
  30.     if (param >= sizeof fpelist/sizeof fpelist[0]) error("floating exception");
  31.     else error(fpelist[param]);
  32. }
  33.  
  34. fppinit()
  35. {
  36.     signal(SIGFPE, fpe);
  37. }
  38.