TESTD.C 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <conio.h>
  16. #include "div0.h"
  17. extern void correct();
  18. extern int testdivide();
  19. extern void div0_my_add();
  20. extern void setup_correct();
  21. void correct_c()
  22. {
  23. printf( "Divide by zero error, man!\n" );
  24. }
  25. main()
  26. { int x,y,z;
  27. printf( "\n\n\n\n" );
  28. if (!div0_init( DM_SATURATE )) {
  29. printf( "Error initializing Divide By Zero Exception.\n" );
  30. exit(1);
  31. }
  32. z = 0;
  33. printf( "The following should saturate on divide by zero.\n" );
  34. printf( "A result of 3 (ie... 6 2) will continue...\n" );
  35. while(z != 3)
  36. {
  37. printf( "Enter two integers: " );
  38. scanf( "%d %d", &x, &y );
  39. z = x / y;
  40. printf( "%d / %d = %d\n", x, y, z );
  41. }
  42. //div0_set_handler( div0_my_add, correct );
  43. setup_correct();
  44. z = testdivide();
  45. printf( ".\n.\n.This should equal 15 (from TESTDA.ASM): %d\n", z );
  46. printf( "\nPress any key...\n" );
  47. getch();
  48. div0_set_mode( DM_ERROR );
  49. printf( "\nNow, you should see the Watcom runtime error message...\n" );
  50. printf( "\nPress any key...\n" );
  51. getch();
  52. x = y = 0;
  53. z = x / y;
  54. printf( "Z=%d\n", z );
  55. div0_close();
  56. }