Page 1 of 1

Installing the IDT in Assembly

Posted: Sat Apr 24, 2010 11:01 pm
by HitmanYesman
I'm having trouble creating the IDT in Assembly. This is what I have so far for my IDT.inc file:

Code:

Code: Select all

;***************************************;
;   IDT.inc                        ;
;***************************************;
bits   32

;=======================================;
;   Include Files                  ;
;=======================================;


;=======================================;
;   Install_IDT                     ;
;=======================================;
Install_IDT:
   pusha
   lidt         [IDT_Desc]
   popa
   ret

;=======================================;
;   IDT - Interrupt Descriptor Table   ;
;=======================================;
IDT_General:
   mov         ax, 0x12
   call         Set_Text_Color
   call      ClrScr32
   mov         ax, 0x01F
   call      GotoXY
   mov         ebx, msg
   call      Puts32
   
   jmp         $

IDT_End:

IDT_Desc:   
   dw         IDT_General - IDT_End - 1
   dd         IDT_General

;=======================================;
;   Data                        ;
;=======================================;
msg   db "*** [i86 Hal] i86_default_handler: Unhandled Exception", 0x0A, 0x00
IDT_General is going to be the general exception handler for the interrupts I haven't covered yet. I'm pretty sure I have that set up right. But what I'm really confused about is how to set that to all 256 descriptors so it can cover them all.

I'm not sure what to do next in it to get it working. I'm looking at different tutorials about the IDT and I know what they're saying but implementing it is harder than I thought. It's because they're all in C/C++. If you know one in Assembly please let me know. And please don't (if your going to help me here) just give me the code, I want to work this out on my own.

Re: Installing the IDT in Assembly

Posted: Sat Apr 24, 2010 11:23 pm
by thepowersgang
May I suggest you look at the tutorials on the wiki, because you have no clue about how the IDT works. The IDT descriptor points to an array of 8-byte entries that describe the handlers for each of the 256 interrupts, not to a general handler.

Re: Installing the IDT in Assembly

Posted: Sat Apr 24, 2010 11:26 pm
by HitmanYesman
I am well aware that you don't use a general one. It is simply a test to see if it would work. And I read this other tutorial that used a general ISR for all the interrupts that weren't covered yet. I'll look it up on the wiki and see if I can figure this out.

Re: Installing the IDT in Assembly

Posted: Sun Apr 25, 2010 12:01 am
by TylerH
No, seriously, go read the wiki. You are way off. The IDT(the stuff you have between IDT_General and IDT_End) shouldn't even contain code at all. It's similar to the IVT, it only tells the processor where it can find the code to handle the interrupt. You IDT should contain a bunch of descriptors that will point to the code(similar to how the GDT works) and have some other info about the function of the interrupt such as what ring the ISR is to be run in.