Divide By 0 ISR

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
ash

Divide By 0 ISR

Post by ash »

Hi, when a divide by 0 ISR is called, it repeatedly gets called. Ive heard that you not to pop the error code off the stack. But I cant seem to do that. I keep getting general protection faults? Any ideas? this is my ISR:

[extern interrupt_handler]
[global int_00]
int_00:
pusha
push ds
push es
push fs
push gs

mov eax, 0x00
push eax
call interrupt_handler ; Divide by Zero #DE
pop eax

pop gs
pop fs
pop es
pop ds
popa
iret

ta, ash
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Divide By 0 ISR

Post by Pype.Clicker »

better check the holly manual, but i think division by zero has a return address that point to the faulty division. Thus if you simply return, it will fire the division exception again and again. What you have to do here is HaLTing ...
ash

Re:Divide By 0 ISR

Post by ash »

Do you have to buy the Intel Manual. Or is it free to download? thx ash.
slacker

Re:Divide By 0 ISR

Post by slacker »

you can download it or send intel your name and they will send 3 fat FREE books....
Peter_Vigren

Re:Divide By 0 ISR

Post by Peter_Vigren »

slacker wrote: you can download it or send intel your name and they will send 3 fat FREE books....
You can!?!? Free books as in really, really free books? And does this work outside US?
Tim

Re:Divide By 0 ISR

Post by Tim »

Yes. I've heard of people in Europe and Australia receiving free books shipped from the US.
Peter_Vigren

Re:Divide By 0 ISR

Post by Peter_Vigren »

Okay... Do you have a direct link to the ordering page? I have trouble finding any (Intel's site makes me dizzy to say the least...)...

By the way, sorry because this is a bit off topic...
bkilgore

Re:Divide By 0 ISR

Post by bkilgore »

I went to the intel site, and unfortunately it says they're not available right now. It does give a 1-800 number to call to get them directly. Let me know if you try this and it works out. The documents are available online at: http://developer.intel.com/design/pentium4/manuals/ and the site to request hardcopies is: http://developer.intel.com/design/pentium4/manuals/index2.htm

- Brandon
Peter_Vigren

Re:Divide By 0 ISR

Post by Peter_Vigren »

It's up again. But it seems that it is only for companies... you have to fill in a company name...
Jamethiel

Re:Divide By 0 ISR

Post by Jamethiel »

If they want a company name, give them one. It's not like they'll check it or anything.
mr. xsism

Re:Divide By 0 ISR

Post by mr. xsism »

a suggestion for the repeating: pop the address and increment the pointer, then return. This depends on the opcode size, but that would work if you could inc the right number of bytes to skip the errorneuos divide code.

Regards,
mr. xsism
elias

Re:Divide By 0 ISR

Post by elias »

im looking to get these books too. i have searched intels developer site to no avail. i can never find anythign on that site. what exactly do i have to send?
The Pro from Dover

Re:Divide By 0 ISR

Post by The Pro from Dover »

mr. xsism wrote: a suggestion for the repeating: pop the address and increment the pointer, then return. This depends on the opcode size, but that would work if you could inc the right number of bytes to skip the errorneuos divide code.
With this sort of exception, returning to the running code at the point following the error is a Bad Thing; the code in question is expecting the preceeding computation to have completed with a meaningful result, when in fact the values in question are in an indeterminant state.

The simplest practical solution is to kill the running process and return a failure message of some kind. Not very elegant, but completely general and unlikely to cause a catastophic data corruption later down the line. Halting the process and asking if the user want to open a debugger session is a bit more useful, at least for users who are also programmers.

The Right Thing would be to re-enter the process and raise an exception, so that the program itself could handle the problem sensibly; if the program doesn't trap the error, then halt and ask to open a debugger session. This, however, depends on the language that the app is written in having an exception handling mechanism which can work with your system's exception handlers.

Or perhaps the real Right Thing is to have sanity checks in the code itself, either added manually or inserted by the compiler or interpreter automagically; the extra overhead of the checking would still be less than the overhead of trapping a system exception. Just a thought. ;D
Post Reply