News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

idt

Started by ninjarider, July 23, 2007, 07:22:33 PM

Previous topic - Next topic

ninjarider

currently trying to see how the idt works. i know what the intel manual says im just wanting to see it work. i currently have my box at the house with a small program on a floppy boot secter the program loads the value of idt to 7e00h and the displays the values of it from there. my program i believe is currently displaying 0044000000000000h not quite sure if those are the values they should be since the maximum the idt should be is 256 one byte. i dont think that im either reading the values right or not.

im using sidt intruction with an fword ptr to memory address 7e00h
i then display each byte starting at 7e00h 1 at a time
concidering it boots up i figure that the base might or could be 0 but the limit should be 90h and thats what im not seeing.

MichaelW

IIRC, assuming the maximum 256 vectors, with 8 bytes per descriptor, the IDT can occupy up t0 256*8 bytes. If you are running in real mode, big or otherwise, then I doubt that the value in the IDTR has any meaning (although I have never actually tested this).
eschew obfuscation

ninjarider

if the value of the idtr has to have a meaning and valid. how else when you call int 16h does the computer know that you want to do something with the keyboard.

ninjarider

done some reading and found that in real mode after a boot it is not the idt what controls the interrupts but the ivt -interrupt vertor table- anyways the ivt starts at physical address 0 and each entry consist of 4 byte. 2 words each the lower being the offset and the upper being the segment. time to have fun.
:bdg

MichaelW

Yes, a real mode interrupt vector table is very different from a protected mode IDT. I was guessing that since the real mode interrupt handling is a holdover from the first x86 processors Intel had not connected it to the protected mode interrupt handling, but apparently I was wrong. The attachment is a real mode app that displays the contents of the IDTR, and under Windows 98 FE MS-DOS mode I get what appear to be a reasonable values.

Under Windows 2000:

IDT base        80036400
IDT limit       07FF

Under Windows 98 FE:

IDT base        C000D474
IDT limit       02FF

Under Windows 98 FE MS-DOS mode:

IDT base        00000000
IDT limit       FFFF


I had never noticed that SGDT, SIDT, and SLDT are not privileged instructions.


[attachment deleted by admin]
eschew obfuscation

ninjarider

i was trying to display the ivt that the bios has at start up. im slowly in the process of building an os. i was wondering what the idt/ivt (the only difference is that the ivt has word size entries and the idt has dword size entries.) was so that i can try reverse engineering what the bios has to try learning stuff from them.

i think i was getting something like 0000:4400h when i read the bios. wait thinking about it that is valid. i was thinking it followed the layout of the idt. 1 dword and 1 word. physical address and limit. the ivt has just offset segment i believe

MichaelW

This is the boot sector code that I used to capture the interrupt vectors. The code is 15+ years old, so if you are using MASM 6.0 or later bin2data is not necessary and you can set the origin to 7C00h. The BIOSDUMP.EXE referred to in the message was a QB app that I used to investigate various things related to the BIOS. I used it to, among other things, create the boot disk, read the vectors from the disk, and display or print them.

;BOOTCODE.ASM --> BOOTCODE.BIN
;Boot code for copying interrupt vectors (as initialized by BIOS) to diskette
;Copy code to boot disk at track 0  head 0  sector 1 (boot record)
;Vectors copied to physical sectors 8 and 9
;BIOS will load boot record at 0000:7C00 and pass control to it
;Some BIOS's may look for near or far jump at start of code

_TEXT   segment
    assume cs:_TEXT, ds:_TEXT, ss:_TEXT
    org 0h                  ;exe2bin will not accept 7C00h
entry:
    jmp start
start:
    cli
    xor ax,ax
    mov ss,ax
    mov sp,7C00h            ;stack below code
    mov ds,ax
    mov es,ax
    cld
    mov ax,0302h            ;write 2 sectors
    mov cx,8                ;ch = track, cl = sector
    xor dx,dx               ;dh = head, dl = drive 0
    xor bx,bx               ;es:bx -> buffer
    sti
    int 13h

    ;All data offsets must be adjusted for actual load offset
    mov si,offset msg2 + 7C00h      ;assume no error
    or  ah,ah
    jz  noError             ;jump if no error
    mov si,offset msg1 + 7C00h      ;error msg
noError:
    call    PrintString
dynamicHalt:
    jmp dynamicHalt

PrintString proc
    mov ah,0Eh              ;write teletype
    xor bx,bx               ;page 0
printLoop:
    lodsb
    or  al,al
    jz  endOfString         ;stop at first null byte
    int 10h
    jmp short printLoop
endOfString:
    ret
PrintString endp

msg1    db  13,10,13,10," Diskette error writing interrupt vectors..."
    db  "correct problem and reboot",13,10,0
msg2    db  13,10,13,10," Interrupt vectors copied..."
    db  "remove disk, reboot, and restart BIOSDUMP.EXE",13,10,0

    org 510
signature:
    db  55h,0AAh

_TEXT   ends
    end entry

eschew obfuscation

ninjarider

anybody got a dell optiplex 240gx with the a05 bios update from dell to compair the contents of the interrupt discriptor table values. not talking about the idt register.

cekic

again hi:)
don't understand me wrongly please...
but I beat myself abaout these numbers this is the first question in this topic...you ssaid that (;BIOS will load boot record at 0000:7C00 and pass control to it)
above..and I want to ask that how can I have information about numbers like this 0000:7c00 sth else in assemly code...I open a topic about numbers for this subject but maybe I couldn't tell you about my question:(
the second question is what is the IDT can you tell me about it ?
and again sorry about my bad english
and please don't understand me wrongly about I m flooding or doing mistakes
god bless you
thnx for your helps

MichaelW

The 0000:7C00 is an address in segment-offset format that consists of a segment address of 0000h and an offset address of 7C00h. Addresses in the BIOS data area, which is located in segment 40h, are frequently expressed in a similar format, for example 40:6C, which is the address of the DWORD where the BIOS stores the count of timer ticks since midnight.

For a description of IDT (in English), one good source would be the Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 3B: System Programming Guide, available here.

I have never checked the availability of the Intel manuals in other languages, but it might be worth a try starting here.
eschew obfuscation