flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Load IDT to Operating System

Author
Thread Post new topic Reply to topic
IsaacZ



Joined: 05 Dec 2025
Posts: 7
IsaacZ 13 Jan 2026, 18:46
I've recently been trying to make a Protected Mode OS, I disabled interrupts, enabled A20, and loaded GDT. I'm now struggling to find how to add IDT to my OS. I've literally been looking all day. Anyways here's my code so far, i just need to know how i can load IDT and what i can improve.

Code:
;[Y] CLEAR INTERRUPTS
;[Y] ENABLE A20 LINE
;[Y] LOAD IN GDT (Global Descriptor Table)
;[-] LOAD IN IDT (Interrupt Descriptor Table)

org 0x7C00
use16

bootloader:
    cli
    xor ax, ax
    mov ds, ax
    mov es, ax
    mov ss, ax
    mov sp, 0x7C00

enable_a20:
    in al, 0x92
    or al, 0x2
    out 0x92, al

load_gdt:
    lgdt [gdt_descriptor]
    mov eax, cr0
    or eax, 1
    mov cr0, eax
    jmp 0x08:start_protected

use32
start_protected:
    mov ax, 0x10
    mov ds, ax
    mov es, ax
    mov fs, ax
    mov gs, ax
    mov ss, ax
    mov esp, 0x90000

;MAIN FOR NOW
    mov edi, 0xB8000
    mov al, '?'
    mov ah, 0x0F
    mov [edi], ax

    jmp $

gdt_start:
gdt_null:
    dd 0x0
    dd 0x0
gdt_code:
    dw 0xFFFF
    dw 0
    db 0
    db 10011010b
    db 11001111b
    db 0
gdt_data:
    dw 0xFFFF
    dw 0
    db 0
    db 10010010b
    db 11001111b
    db 0
gdt_end:
gdt_descriptor:
    dw gdt_end - gdt_start - 1
    dd gdt_start

times 510-($-$$) db 0
dw 0xAA55
    

By the way, I did test this and it boots on Dell Optiplex 7010 (Real hardware not on vm).

_________________
OpenRodent Operating System: https://lightdarksoft.neocities.org/openrodent
Post 13 Jan 2026, 18:46
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20825
Location: In your JS exploiting you and your system
revolution 13 Jan 2026, 19:43
Would that be LIDT?
Post 13 Jan 2026, 19:43
View user's profile Send private message Visit poster's website Reply with quote
IsaacZ



Joined: 05 Dec 2025
Posts: 7
IsaacZ 13 Jan 2026, 20:39
revolution wrote:
Would that be LIDT?

I probably didn't word it right, My problem is setting up IDT, and adding it to my operating system, LIDT shouldn't be that hard.

_________________
OpenRodent Operating System: https://lightdarksoft.neocities.org/openrodent
Post 13 Jan 2026, 20:39
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8500
Location: Kraków, Poland
Tomasz Grysztar 13 Jan 2026, 21:59
My old minimalistic long mode example (originally posted here) has a simple setup with clock and keyboard IRQs handled. It's not that much different in 32-bit case.

And on the opposite end, during my live streams back in 2019 I developed a 16-bit protected mode example that includes setting up the IDT. The videos document how it was put together.
Post 13 Jan 2026, 21:59
View user's profile Send private message Visit poster's website Reply with quote
IsaacZ



Joined: 05 Dec 2025
Posts: 7
IsaacZ 13 Jan 2026, 22:44
Tomasz Grysztar wrote:
My old minimalistic long mode example (originally posted here) has a simple setup with clock and keyboard IRQs handled. It's not that much different in 32-bit case.

And on the opposite end, during my live streams back in 2019 I developed a 16-bit protected mode example that includes setting up the IDT. The videos document how it was put together.

Thank you! I'll definitely try that after i fix another problem (booting to kernel) since IDT won't fit in the 512 byte bootloader lol. Thanks again for helping, and for fasm!

_________________
OpenRodent Operating System: https://lightdarksoft.neocities.org/openrodent
Post 13 Jan 2026, 22:44
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.