i have a question regarding interrupts in real mode. I understand that the first 20 interrupts in real mode are cpu exception interrupts. I tried to redirect them to my own error handling interrupt, so that i can inform the user that a double fault or divide by zero or something like that occurred and then restart the system.
If i do this for e.g. interrupt 0 (divide by zero) this works fine. Upon an illegal division the system informs me and halts, or if no illegal division is executed, operates normal.
However, if i try to do this for the interrupt 8 (double fault), i am getting double fault errors consistently the fourth time i try to read the floppy.
Here is some of the code i use:
Overwriting the ivt:
Code: Select all
; Double Fault
mov [ds:0x20], word _critical_double_fault
mov ax, cs
mov [ds:0x20 + 2], ax
Code: Select all
_critical_double_fault:
pusha
push ds
mov ax, cs
mov ds, ax
; This is a macro calling a software interrupt, printing the message with error code 8 and then halting the system, effectifely making everything below this macro useless
critical_println .error_msg, 8
pop ds
end_of_interrupt
popa
iret
.error_msg db 'Double fault!', 0
The error occurs on ch=0, cl=5, dh=1, dl=0, es:bx=0x03400
Code: Select all
mov ah, 0x02 ; Read device es:bx
mov al, 0x01 ; Number of sectors to read
mov ch, byte [__lba_chs_absolute_track] ; track
mov cl, byte [__lba_chs_absolute_sector] ; sector
mov dh, byte [__lba_chs_absolute_head] ; head
mov dl, byte [bsDriveNumber]
int 0x13
jnc .done ; test if succeeded
If i do not alter the ivt for interrupt 8, there is no problem in reading the floppy disk, neither is the interrupt being called. I set a breakpoint on the start of the interrupt handler (0xffea5) to verify this.
Has somebody had a similar problem or knows why the double fault interrupt is called only if i change the ivt? Is it okay to overwrite the cpu exception interrupts?