OSDev.org
https://forum.osdev.org/

Problems with ISR
https://forum.osdev.org/viewtopic.php?f=1&t=33395
Page 1 of 1

Author:  cyann [ Thu Dec 27, 2018 9:16 am ]
Post subject:  Problems with ISR

Hello!
I have a small problem with getting interrupts to work.
When I put for example
Code:
asm("int $0x00");
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?

Author:  Octacone [ Thu Dec 27, 2018 10:48 am ]
Post subject:  Re: Problems with ISR

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?

Author:  cyann [ Thu Dec 27, 2018 2:30 pm ]
Post subject:  Re: Problems with ISR

Stupid me, I didn't know that iret expects an unchanged stack.
Thank you for your input, problem solved :D

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/