idt_zero_divide.S 429 B

123456789101112131415161718192021222324
  1. #include "common.h"
  2. BEGIN
  3. STAGE2
  4. CLEAR
  5. PROTECTED_MODE
  6. IDT_SETUP_ENTRY $0, $handler
  7. lidt idt_descriptor
  8. mov $0, %edx
  9. mov $1, %eax
  10. mov $0, %ecx
  11. /* The iret jumps back here. */
  12. div %ecx
  13. jmp .
  14. IDT_START
  15. IDT_ENTRY
  16. IDT_END
  17. handler:
  18. VGA_PRINT_STRING $message
  19. /* If we don't do this, we get an infinite loop. */
  20. mov $1, %ecx
  21. iret
  22. message:
  23. .asciz "division by zero handled"