isr for interrupt 0

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
northfuse

isr for interrupt 0

Post 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
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Re:isr for interrupt 0

Post by Perica »

..
Last edited by Perica on Sun Dec 03, 2006 9:25 pm, edited 1 time in total.
mr. xsism

Re:isr for interrupt 0

Post 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??
Ozguxxx

Re:isr for interrupt 0

Post by Ozguxxx »

It is the address that is pushed which is 32 bits, why do you need opcode size?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:isr for interrupt 0

Post 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.)
Every good solution is obvious once you've found it.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:isr for interrupt 0

Post 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?
Ozguxxx

Re:isr for interrupt 0

Post 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.
Therx

Re:isr for interrupt 0

Post 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.
mr. xsism

Re:isr for interrupt 0

Post 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.
Post Reply