Hi all. I want to learn all register values and interrupt number after an interrupt exception.
My ISR Code:
in asm:
-------------------
isr0:
pushad
push ds
push es
push fs
push gs
; C Code
call _interrupt_occured
pop gs
pop fs
pop es
pop ds
popad
iret
C Code:
---------------------
void interrupt_occured()
{
video.write( "EXCEPTION" );
}
How can i learn register values and interrupt number in interrupt_occured function?
Thanks.
Interrupt Results
Re:Interrupt Results
Hi, I assume you want the register state inside the ISR because if you want after or even before the handler, the ESP value differs. So which ever point you want to take the "snapshot" of registers you can make a structure that corresponds with what was pushed onto stack prior to calling interrupt_occured or use a prototype with parameters that matches what as previously pushed onto stack.
The one option I mentioned, creating a structure form:
And the parameter way..
Theres probably dozen ways to do this, you may also want a static location to store register information to avoid stack usage.. well I hope this helps.
edit: I forgot to mention, if you want the interrupt number just push the number like a normal parameter and ofcourse you add that in the prototype.
The one option I mentioned, creating a structure form:
Code: Select all
pushad
push ds
push es
push fs
push gs
push esp
call _interrupt_occured
------ C Source ----------
struct REGISTER_STATE {
unsigned int GS, FS, ES, DS, EDI, ESI, EBP, ESP, EBX, EDX, ECX, EAX;
};
void interrupt_occured(REGISTER_STATE* state)
{
video.write( "EXCEPTION" );
video.fprintf( "GS 0x%u", state->GS); // you get the point..
}
Code: Select all
pushad
push ds
push es
push fs
push gs
call _interrupt_occured
------ C Source ----------
// lets pretend this is a stdcall where arguments pushed right to left and yes this messy messy..
void interrupt_occured(unsigned int GS, unsigned int FS, unsigned int ES, unsigned int DS, unsigned int EDI, unsigned int ESI, unsigned int EBP, unsigned int ESP, unsigned int EBX, unsigned int EDX, unsigned int ECX, unsigned int EAX)
{
video.write( "EXCEPTION" );
video.fprintf( "GS 0x%u", GS); // printout whats in GS register
}
edit: I forgot to mention, if you want the interrupt number just push the number like a normal parameter and ofcourse you add that in the prototype.