Page 1 of 1
Problems with ISR
Posted: Thu Dec 27, 2018 9:16 am
by cyann
Hello!
I have a small problem with getting interrupts to work.
When I put for example
in my code, the corresponding ISR is being called fine. The problem is that if I put any
push instructions in the ISR, the whole system crashes. I can do
iret,
mov fine and no problems occur. But if I try to do even something like
push dword 0 the whole OS simply crashes. Can sombody help me with that?
Re: Problems with ISR
Posted: Thu Dec 27, 2018 10:48 am
by Octacone
You can't just push things randomly and except it work. Everything that gets pushed has to get popped. (most of the time)
Your stack (stack frame) has to be consistent in order for iret to work fine. It contains things such as CS and EIP and expects them in a certain order. If you push some random junk onto the stack, you will mess up those values and their locations, resulting in a fault.
Once an interrupt happens the code that your processor was running beforehand gets "put to sleep" and your interrupt handler gets executed. If your interrupt handler doesn't save all the registers that the previous program used, it is likely that a fault will occur (because the stack will get messed up).
Could you show us your interrupt handling code?
Re: Problems with ISR
Posted: Thu Dec 27, 2018 2:30 pm
by cyann
Stupid me, I didn't know that
iret expects an unchanged stack.
Thank you for your input, problem solved