OSDev.org

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

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Interrupt Vector Table Article
PostPosted: Wed Apr 06, 2011 6:48 am 
Offline

Joined: Fri Jan 14, 2011 8:13 pm
Posts: 5
Hi,

I noticed that the Interrupt Vector Table page in the wiki lacks a piece of information vital to the reading and modification of the IVT: It does not mention that the memory addresses stored in the interrupt vectors are in reverse.

For example, modifying the interrupt vector of interrupt 0x21 to point to 0x7650:0x7B4F:

According to the article, once the interrupt vector is written, it should look like this:

Code:
0x76 0x50 0x7B 0x4F


A simple, but probably not the most efficient way to do this in x86 (NASM) assembly, would be:

Code:
mov ax, 0x7650
mov es, ax
mov WORD [es:0x0000], 0x7B4F  ; Put the offset of INT 0x00 in the IVT
mov WORD [es:0x0002], ax        ; Put the segment of INT 0x00 in the IVT


But I ran into a problem when doing this, and I discovered that when I invoked my interrupt, the CPU would jump somewhere seemingly arbitrary. After careful debugging and research, I discovered that the memory addresses stored in the interrupt vectors were in reverse.

Therefore, once the interrupt vector is written, it should look like this:

Code:
0x4F 0x7B 0x50 0x76


A simple, but probably not the most efficient way to do this in x86 (NASM) assembly, would be:

Code:
mov ax, 0x7650
mov es, ax

mov ax, 0x7B4F

mov BYTE [es:0x0000], al          ; Put the offset of INT 0x00 in the IVT
mov BYTE [es:0x0001], ah         ; Put the offset of INT 0x00 in the IVT

mov ax, 0x7650

mov BYTE [es:0x0002], al          ; Put the segment of INT 0x00 in the IVT
mov BYTE [es:0x0003], ah         ; Put the segment of INT 0x00 in the IVT


I would be grateful if someone could please add this information to the wiki, as it would save people like me a few hours of (unnecessary) debugging. I didn't attempt to add this information to the wiki myself because I wasn't sure of any standards and if it was even worth adding to the wiki.

Thanks,

-U238


Top
 Profile  
 
 Post subject: Re: Interrupt Vector Table Article
PostPosted: Wed Apr 06, 2011 7:08 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
You're making a mistake yourself:
Code:
mov ax, 0x7B4F
mov BYTE [es:0x0000], al          ; Put the offset of INT 0x00 in the IVT
mov BYTE [es:0x0001], ah         ; Put the offset of INT 0x00 in the IVT
is exactly equivalent to
Code:
mov WORD [es:0x0000], 0x7B4F  ; Put the offset of INT 0x00 in the IVT
and thus does not make any difference. If you disagree, read up on byteorders.


Perhaps there is something else wrong?

_________________
"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 ]


Top
 Profile  
 
 Post subject: Re: Interrupt Vector Table Article
PostPosted: Wed Apr 06, 2011 7:14 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 26, 2009 2:48 am
Posts: 792
U238 wrote:
But I ran into a problem when doing this, and I discovered that when I invoked my interrupt, the CPU would jump somewhere seemingly arbitrary. After careful debugging and research, I discovered that the memory addresses stored in the interrupt vectors were in reverse.
Well, the x86 architecture is little-endian, but that is not the problem here. The problem is that you are not writing the IVT at all. The IVT is not located at 76500H but at 00000H.
Code:
mov ax, 0x7650
mov es, ax
mov WORD [es:0x0000], ...


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: No registered users and 20 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