2018-12-04 09:46:27 +00:00
|
|
|
/* https://github.com/cirosantilli/x86-bare-metal-examples#idt-divide-by-zero */
|
|
|
|
|
|
2015-10-21 21:41:07 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
BEGIN
|
|
|
|
|
STAGE2
|
|
|
|
|
CLEAR
|
|
|
|
|
PROTECTED_MODE
|
2015-10-23 17:57:12 +02:00
|
|
|
IDT_SETUP_ENTRY $0, $handler
|
2015-10-21 21:41:07 +02:00
|
|
|
lidt idt_descriptor
|
2015-10-21 22:48:56 +02:00
|
|
|
mov $0, %edx
|
|
|
|
|
mov $1, %eax
|
|
|
|
|
mov $0, %ecx
|
2018-05-06 14:33:33 +01:00
|
|
|
/* The iret jumps back here. */
|
2015-10-21 22:48:56 +02:00
|
|
|
div %ecx
|
2015-10-21 21:41:07 +02:00
|
|
|
jmp .
|
2015-10-23 17:57:12 +02:00
|
|
|
IDT_START
|
|
|
|
|
IDT_ENTRY
|
|
|
|
|
IDT_END
|
2015-10-21 21:41:07 +02:00
|
|
|
handler:
|
|
|
|
|
VGA_PRINT_STRING $message
|
2018-05-06 14:33:33 +01:00
|
|
|
/* If we don't do this, we get an infinite loop. */
|
2015-10-21 22:48:56 +02:00
|
|
|
mov $1, %ecx
|
2015-10-21 21:41:07 +02:00
|
|
|
iret
|
|
|
|
|
message:
|
2015-10-28 18:36:31 +01:00
|
|
|
.asciz "division by zero handled"
|