-
Notifications
You must be signed in to change notification settings - Fork 0
Interrupt Descriptor Table (IDT)
randcode-generator edited this page Sep 10, 2014
·
5 revisions
The offset in the interrupt descriptor table is the offset of the interrupt handler (or function) to be called when interrupt is signaled.
Notice that the function interrupt0 is at 0xD2 and interrupt1 is at 0xE6. The full code is at code 2 section
140 interrupt0:
141 000000D2 8D05[18000000] lea eax, [intMessage0] ; load address of msg to eax
142 000000D8 50 push eax ; push into stack (this will be parameter 1)
143 000000D9 6A00 push 0 ; x
144 000000DB 6A01 push 1 ; y
145 000000DD E8A2FFFFFF call print
146 000000E2 83C40C add esp,12 ; pop off the stack
147 000000E5 CF iret
148
149 interrupt1:
150 000000E6 8D05[25000000] lea eax, [intMessage1] ; load address of msg to eax
151 000000EC 50 push eax ; push into stack (this will be parameter 1)
152 000000ED 6A00 push 0 ; x
153 000000EF 6A02 push 2 ; y
154 000000F1 E88EFFFFFF call print
155 000000F6 83C40C add esp,12 ; pop off the stack
156 000000F9 CF iret
The offset for interrupt 1 is 0xD2 + 0x7c00 (remember we start at 0x7c00 therefore, our offset is 0x7cd2). The offset for interrupt 0 is 0xE6 + 0x7c00 (0x7ce6). The full code is at code 1 section
; interrupt 0
db 0xD2,0x7c ; offset(0:15)-address of interrupt 1 function (handler)
dw 8 ; code segment (0x08)
db 0 ; hard coded all zeros
db 10001110b ; 1000b
; 1-segment present flag
; 00-privilage level
; 0-hard coded value
; 1110b
; 1-size of gate 1-32 bit, 0-16 bit
; 110-hard coded value for type interrupt gate
db 0,0 ; offset(16:31)
; interrupt 1
db 0xE6,0x7c ; address of interrupt 0 function (handler)
dw 8 ; code segment (0x08)
db 0 ; hard coded all zeros
db 10001110b ; 1000b
; 1-segment present flag
; 00-privilage level
; 0-hard coded value
; 1110b
; 1-size of gate 1-32 bit, 0-16 bit
; 110-hard coded value for type interrupt gate
db 0,0 ; offset(16:31)
Code 1 : Added interrupt descriptor table