DIV0.H 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/div/rcs/div0.h $
  15. * $Revision: 1.2 $
  16. * $Author: john $
  17. * $Date: 1994/01/14 15:34:25 $
  18. *
  19. * Header file for divide by zero handler
  20. *
  21. * $Log: div0.h $
  22. * Revision 1.2 1994/01/14 15:34:25 john
  23. * Added counters for number of overflows.
  24. *
  25. * Revision 1.1 1993/09/17 12:37:58 john
  26. * Initial revision
  27. *
  28. *
  29. */
  30. // D I V 0 . H
  31. //==========================================================================
  32. // These are constants passed for the default mode. If the address of the div
  33. // instruction is not in the Callback (CB) list and also not in the
  34. // Saturate (SAT) list, then the default mode will be used. It will either
  35. // do an int 3 and then dump the registers and break to DOS (DM_ERROR)
  36. // or else it will saturate the result and allow the program to continue
  37. // if DM_SATURATE is specified.
  38. #define DM_ERROR 0
  39. #define DM_SATURATE 1
  40. //==========================================================================
  41. // This initializes and grabs the Divide by 0 Exception. See above for mode.
  42. // Returns 1=Installed OK, 0=Failed. Failed probably means old DPMI host, but
  43. // I think that as long as we use DOS4GW v1.90 or higher we're ok.
  44. extern int div0_init(int mode);
  45. extern void div0_close(); // Closes it.
  46. //==========================================================================
  47. // Sets the default handler behavior. See above constant descriptions.
  48. extern void div0_set_mode(int mode);
  49. //==========================================================================
  50. // Adds a handler to the list of handlers to jump to whem an overflow occurs.
  51. // All registers, etc should be exactly as before the DIV instruction. This
  52. // doesn't work within C. This returns 1 if ok, and 0 if there isn't any more
  53. // "slots" available. The number of slots can be changed in div0.asm by
  54. // changing the MAX_SIZE constant. MAX_SIZE = 100 now.
  55. // In ASM, the parameters are:
  56. // EAX = *div_addr, EDX=*handler_addr, Return value in EAX.
  57. extern int div0_set_handler( void *div_addr, void *handler_addr );
  58. //==========================================================================
  59. // Same as above, but saturates the result instead of jumping to a handler.
  60. // Doesn't need the void*handler_addr parameter. Uses the same MAX_SIZE.
  61. extern int div0_set_saturate( void *div_addr );
  62. //==========================================================================
  63. // These three variables count the number of times the divide by zero handler
  64. // has been used.
  65. // - div0_num_handled_by_cblist is the number of times a divide exception
  66. // has occurred and was corrected by calling a user-specified function.
  67. // - div0_num_handled_by_satlist is the number of times a divide exception
  68. // has occured and the result was saturated because it specifically was
  69. // in the saturation list.
  70. // - div0_num_saturated are the divides that aren't handled by the programmer
  71. // explicitly, but the handler went ahead and sautrated anyway. These
  72. // probably shouldn't be happening very often.
  73. extern int div0_num_handled_by_cblist;
  74. extern int div0_num_handled_by_satlist;
  75. extern int div0_num_saturated;
  76.