OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:48 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Problems with ISR
PostPosted: Thu Dec 27, 2018 9:16 am 
Offline

Joined: Thu Dec 27, 2018 9:06 am
Posts: 2
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?


Top
 Profile  
 
 Post subject: Re: Problems with ISR
PostPosted: Thu Dec 27, 2018 10:48 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
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?

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Top
 Profile  
 
 Post subject: Re: Problems with ISR
PostPosted: Thu Dec 27, 2018 2:30 pm 
Offline

Joined: Thu Dec 27, 2018 9:06 am
Posts: 2
Stupid me, I didn't know that iret expects an unchanged stack.
Thank you for your input, problem solved :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 70 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group