how do i know which interrupt is firing?
i'm asking because i want to have a single function for all exceptions.
which interrupt?
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:which interrupt?
you cannot tell if you have one single function. One thing you can do, however, is to have several "ISR points" that will push the number of the exception on the stack and then jump to the "common function".
Please note that this will *not* work properly this way. Some exception have an error code, other doesn't. One thing you can do is to push first a "fake" 0 error code for exceptions that has no error code and replace "add esp,4" with "add esp,8".
Code: Select all
EXC0:
push dword 0
jmp _exception_handler
EXC1:
push dword 1
jmp _exception_handler
...
_exception_handler
pushad
;; save data selectors and set them to a well-known value
;; here comes your "real" exception handler. It could for instance be
push esp
call _C_written_exception_handler
add esp,4
;; restore data registers
popad
add esp,4 ;; <-- remove the interrupt number from the stack.
iretd