[solved] C++ - Implementing interupts doesn't work

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
User avatar
max9403
Posts: 17
Joined: Sun Feb 09, 2014 3:25 pm

[solved] C++ - Implementing interupts doesn't work

Post by max9403 »

I'm trying to enable IDT, I'm followed a tutorial from osdever.net to implement it, the rest comes from the wiki's basic setup (can't remember the actual URL, so I included it in Source.zip attachment) written for C. So far as I can tell after reading up about the IDT it should work - at least the assembly (tested through the use of dividing by 0).

I've included the source for my "first" OS, which has basic text output, I'm not sure if it's an oversight or something else that I'm missing. If anyone would be willing to look at it to tell me what's wrong I'd appreciate it a lot, or link me to another tutorial for setting it up in C++ I'd appreciate it as well :mrgreen:

Source.zip - includes both the source and the tutorial
Last edited by max9403 on Fri Apr 11, 2014 8:34 am, edited 1 time in total.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: C++ - Implementing interupts doesn't work

Post by zhiayang »

what you've done is essentially do a "here's my source code fix my game", albeit slightly more civilised and packaged in a zip file.

Try to debug the situation yourself first, then post only the relevant source files.
User avatar
max9403
Posts: 17
Joined: Sun Feb 09, 2014 3:25 pm

Re: C++ - Implementing interupts doesn't work

Post by max9403 »

That's the problem I don't know what is wrong, I've spend time looking for information on it, if you don't want to fix it send me to place where they have a tutorial on how it should be done. I posted all of it as I'm sure I making an oversight somewhere (as it compiles without error).

Edit: Apparently I fixed it somehow as it no longer straight out crashes in bochs when dividing by 0 it just spams a lot of LOCK prefix unallowed so I'm guessing the wrong thing is being called - before bochs would just straight out crash which let me to think that the exception handling wasn't working, sorry I jumped to the wrong conclusion

Edit2: Found the issue (Why allows do you find it when you post for help!):
anyway here was wrong:

Code: Select all

mov %eax, %esp
push %eax
mov %eax, <function to handle exception>
call %eax
pop %eax
changing that to just:

Code: Select all

call <function to handle exception>
fixed it, now to figure out the keyboard XD

edit3: btw the reason I included the tutorial is because it doesn't compile for me with the source they give you "out the box" for me so maybe if someone had come across it before they could say that I shouldn't have even touched it or that just a couple of lines where wrong in the tutorial :P
Post Reply