what interrupt# just occurred???
what interrupt# just occurred???
is there a way to tell what interrupt just occurred without having a seperate interrupt handler? for testing purposes, i have the first 32 interrupts set up in the IDT to point to one ISR that prints "Interrupt" to the screen when it occurs. this works fine, but the same thing happens no matter which interrupt occurs. is there a way to get what interrupt number occurred so that i could output that as well, so that i dont need 32 seperate IDT entries going to 32 seperate labels?
RE:what interrupt# just occurred???
No, Not that i have heard of. Some of the first 32 ints/exceptions have error codes on the stack when they occur, so it will hard to do what you want to do. Just write different ones for the first 32 and then u can use an unhandle_int function for the rest you do not want to use.
RE:what interrupt# just occurred???
I think there is a way read it from the PIC. But I'm not sure. i think it is better to use a small macro. This macro is used 256 times (for every interrupt). It just pushes the interrupt number (a parameter of the macro and hard coded). Then it calls a function. These function has now as a parameter the INT number. For example in nasm:
%macro INT_HANDLER 2
%1:
pushad
push eax
push dword %2
call _interrupt
pop eax
pop eax
call SendEOI
popad
iretd
%endmacro
This macro can now be used as following:
INT_HANDLER INT_00, 0
INT_HANDLER INT_01, 1
INT_HANDLER INT_02, 2
INT_HANDLER INT_03, 3
; ...
INT_?? is now the label where the int_handler starts and _interrupt is a C function: interrupt(long int_num);
SendEOI send the End of Interrupt to the PIC.
%macro INT_HANDLER 2
%1:
pushad
push eax
push dword %2
call _interrupt
pop eax
pop eax
call SendEOI
popad
iretd
%endmacro
This macro can now be used as following:
INT_HANDLER INT_00, 0
INT_HANDLER INT_01, 1
INT_HANDLER INT_02, 2
INT_HANDLER INT_03, 3
; ...
INT_?? is now the label where the int_handler starts and _interrupt is a C function: interrupt(long int_num);
SendEOI send the End of Interrupt to the PIC.
RE:what interrupt# just occurred???
When a software interupt is raise, the return adress is push on the stack. So read this adress and you can get the number of the interrupt, but only for software interupt.