I am writing an OS to run on QEMU, and I have defined custom ISR's, however, when I trigger interrupt using
__asm__ ("int $0");
It is handled correctly, but when I do:
int a = 0;
int b = 5;
int c = b/a;
It results in a handle loop calling this over and over. I have tried clearing the bits and masking and nothing seems to work.
This is the definition for my handle that is linked using extern
void ISR::__interrupt_handler(InterruptRegister *reg) {
disp.print_screen("Recieved interrupt: ");
char s[3];
int_to_string(reg->int_no, s);
disp.print_screen(s);
...
}
interrupt.asm
[extern interrupt_handler]
; Common Interrupt Service Routine
isr_common:
cli ; Disable interrupts
; Save the registers
pusha
mov ax, ds ; Save the data segment
push eax; Save the data segment
mov ax, 0x10 ; Set the data segment to 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
; Call the interrupt handler
push esp ; Push the stack pointer
call interrupt_handler
pop eax ; Pop the stack pointer
; Restore the registers
pop eax
mov eax, 1
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
popa
;Clean the pushed error code
add esp, 8
;sti ; Enable interrupts
iret ; Pops CS, EIP, EFLAGS, SS, ESP
isr0:
push byte 0
push byte 0
jmp isr_common