Exception.c 538 B

12345678910111213141516171819202122232425262728
  1. /* This Hello World simply print out "Hello World" */
  2. #include "pal.h"
  3. #include "pal_debug.h"
  4. int count = 0;
  5. int i = 0;
  6. void handler(PAL_PTR event, PAL_NUM arg, PAL_CONTEXT* context) {
  7. pal_printf("failure in the handler: 0x%08lx\n", arg);
  8. count++;
  9. if (count == 30)
  10. DkProcessExit(0);
  11. DkExceptionReturn(event);
  12. }
  13. int main(void) {
  14. pal_printf("Enter Main Thread\n");
  15. DkSetExceptionHandler(handler, PAL_EVENT_ARITHMETIC_ERROR);
  16. i = 1 / i;
  17. pal_printf("Leave Main Thread\n");
  18. return 0;
  19. }