Interrupt Descriptor Table in x86

Programming, for all ages and all languages.
Post Reply
hello123
Posts: 5
Joined: Sat Feb 07, 2015 4:52 am

Interrupt Descriptor Table in x86

Post by hello123 »

I am trying to implement a boot-loader for x86. The initial version just uses the BIOS interrupt call to print "Hello" on the screen. I am using QEmu along with GDB for going through my code sequentially.
Here is a snippet of the code

Code: Select all

mov ah, 0x0e
mov al, 'H'
int 0x10
mov al, 'e'
The boot-loader starts from address 0x07c00.
From what I understood, the BIOS sets up the Interrupt Descriptor table from address 0x0 till 0x3ff (1024 bytes). The IDT has 256 32bit entries, each entry specifies 16bit segment and 16bit offset which is the address of the Interrupt service routine.
Thus , when I execute

Code: Select all

int 0x10
I should jump to the address pointed by the 17th entry in the IDT. When I checked the contents of the memory 0x10, it contained the following data " 0xf000ff53", so the program should jump to the location 0xfff53 but I found that it instead jumps to 0xc4c71 after executing the

Code: Select all

int 0x10
instruction
Why is this happening??
Last edited by hello123 on Sat Feb 07, 2015 6:52 am, edited 1 time in total.
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: Interrupt Descriptor Table in x86

Post by alexfru »

Are 10 and 0x10 the same thing in your assembler?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Interrupt Descriptor Table in x86

Post by Combuster »

In 0x10 bytes, how many 32-bit entries can you fit?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: Interrupt Descriptor Table in x86

Post by Roman »

As far as I know, the BIOS sets up an IVT, not IDT.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Interrupt Descriptor Table in x86

Post by iansjack »

Roman wrote:As far as I know, the BIOS sets up an IVT, not IDT.
http://en.m.wikipedia.org/wiki/Interrup ... ptor_table
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Interrupt Descriptor Table in x86

Post by iansjack »

*** Sorry, wrong thread ***
Last edited by iansjack on Sat Feb 07, 2015 6:57 am, edited 1 time in total.
hello123
Posts: 5
Joined: Sat Feb 07, 2015 4:52 am

Re: Interrupt Descriptor Table in x86

Post by hello123 »

alexfru wrote:Are 10 and 0x10 the same thing in your assembler?
No I am sorry I have edited my question
hello123
Posts: 5
Joined: Sat Feb 07, 2015 4:52 am

Re: Interrupt Descriptor Table in x86

Post by hello123 »

Combuster wrote:In 0x10 bytes, how many 32-bit entries can you fit?
I am not sure what are you asking me here, but what I meant is 0x10 is an index into the IDT and the address stored in this location i.e. 0x10 should be where ISR should be found. But that does not seem to be happening
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Interrupt Descriptor Table in x86

Post by Combuster »

hello123 wrote:
Combuster wrote:In 0x10 bytes, how many 32-bit entries can you fit?
I am not sure what are you asking me here, but what I meant is 0x10 is an index into the IDT and the address stored in this location i.e. 0x10 should be where ISR should be found. But that does not seem to be happening
That basically means that besides not knowing what's going on and avoiding the question, you also posted more inaccurate information. Which exact address in physical memory do you address? How many 32-bit entries can you fit in 0x10 bytes? As long as we don't know what you're doing wrong exactly, we can't fix it for you.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Interrupt Descriptor Table in x86

Post by iansjack »

should jump to the address pointed by the 17th entry in the IDT. When I checked the contents of the memory 0x10, it contained the following data " 0xf000ff53", so the program should jump to the location 0xfff53 but I found that it instead jumps to 0xc4c71
Just to be sure - you checked location 0x40 (the 17th entry in the IDT)? On my computer, using qemu, after the BIOS has initialized the IDT that location contains 0xC00083F9. That's near enough, allowing for different versions, to what you expect. 0x10 is only the 5th entry in the table.
hello123
Posts: 5
Joined: Sat Feb 07, 2015 4:52 am

Re: Interrupt Descriptor Table in x86

Post by hello123 »

Combuster wrote:
hello123 wrote:
Combuster wrote:In 0x10 bytes, how many 32-bit entries can you fit?
I am not sure what are you asking me here, but what I meant is 0x10 is an index into the IDT and the address stored in this location i.e. 0x10 should be where ISR should be found. But that does not seem to be happening
That basically means that besides not knowing what's going on and avoiding the question, you also posted more inaccurate information. Which exact address in physical memory do you address? How many 32-bit entries can you fit in 0x10 bytes? As long as we don't know what you're doing wrong exactly, we can't fix it for you.
Could you please elaborate your question, because I do not understand what you want to fit in 0x10 bytes. As I have said previously, 0x10 is an interrupt number which is an INDEX into the table IDT which starts at address 0x0 and which contains 32 bit entries, so for example: int 0x0 would mean jump to the address (32 bits) starting at address 0x0 in RAM. I do not know how to say it more clearly.
hello123
Posts: 5
Joined: Sat Feb 07, 2015 4:52 am

Re: Interrupt Descriptor Table in x86

Post by hello123 »

iansjack wrote:
should jump to the address pointed by the 17th entry in the IDT. When I checked the contents of the memory 0x10, it contained the following data " 0xf000ff53", so the program should jump to the location 0xfff53 but I found that it instead jumps to 0xc4c71
Just to be sure - you checked location 0x40 (the 17th entry in the IDT)? On my computer, using qemu, after the BIOS has initialized the IDT that location contains 0xC00083F9. That's near enough, allowing for different versions, to what you expect. 0x10 is only the 5th entry in the table.
No I checked the location 0x10...got my mistake....thanks :) :)
Post Reply