Page 1 of 1

isr for interrupt 0

Posted: Mon Dec 01, 2003 10:45 pm
by northfuse
this is the isr that is called when it gets hardware interrupt zero- divide by zero error:

Code: Select all

_int00:
     pusha
     push ds
     push es
     push fs
     push gs
     mov eax,0x10    ; Data segment
     mov ds,eax
     mov es,eax
    cld
     call _int_00    ; Divide by Zero #DE
     pop gs
     pop fs
     pop es
     pop ds
     popa
     iret
when i try it out, the code loops. maybe it isn't returning to the same instruction instead of skipping it? or maybe i'm completely wrong! plz hlp. thanx

Re:isr for interrupt 0

Posted: Mon Dec 01, 2003 11:27 pm
by Perica
..

Re:isr for interrupt 0

Posted: Tue Dec 02, 2003 12:11 am
by mr. xsism
how would you fix this? I would guess that you increment the pointer on the stack, but how do you know the opcode size to skip over??

Re:isr for interrupt 0

Posted: Tue Dec 02, 2003 12:53 am
by Ozguxxx
It is the address that is pushed which is 32 bits, why do you need opcode size?

Re:isr for interrupt 0

Posted: Tue Dec 02, 2003 3:54 am
by Solar
Ozgunh82, I think xsism meant how to know by how many bytes to increment that address to skip over the current opcode and get to the next...

(No idea myself, didn't delve in there yet.)

Re:isr for interrupt 0

Posted: Tue Dec 02, 2003 5:55 am
by Candy
If the code caused a divide by zero error, some error in the code must exist, so you either send a signal there (pushing the signal handler stuff on the stack, and then returning) or you kill the process, in which case you also do not return.

Why in ***'s name do you want to return?

Re:isr for interrupt 0

Posted: Tue Dec 02, 2003 10:17 am
by Ozguxxx
As far as I can remember int0 is a fault so that cpu returns to faulting instruction rather than instruction that follows it. So cpu calls exception handling routine as long as the exception generating code is still there or you can handle it some another way as Solar told, you skip the exception generating code(did you mean this?) so if you do not do something like I told above in your exception handling routine(_int_00 I think), you will loop forever since exception generating code is there. So killing this process that divides by 0 will most likely be the best way to handle divide by 0 exception.

Re:isr for interrupt 0

Posted: Tue Dec 02, 2003 11:30 am
by Therx
There is little point returning to the program as the variable will not contain an expected value and the program will probally crash again because of that.

Re:isr for interrupt 0

Posted: Tue Dec 02, 2003 11:40 am
by mr. xsism
Solar wrote: Ozgunh82, I think xsism meant how to know by how many bytes to increment that address to skip over the current opcode and get to the next...

(No idea myself, didn't delve in there yet.)
exactly what i was asking solar, thanks. It would PROBABLY be better to just kill the process because the value it was trying to get will be incorrect and the app may crash due to that.

Besides, now that i think of it, exceptions are ment to alert the system so that it may kill the process or problem code.