idt_zero_divide.S 511 B

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