They're calling him "mr has a working custom GDT"

...
...
...I'm sorry they don't call me that.
This commit is contained in:
lordtet 2025-06-10 23:58:28 -04:00
parent b127a659bb
commit 8fadee6baf

View file

@ -90,8 +90,20 @@ section .text
;Here it is!
start:
;We made a GDT! Let's use it!
lgdt [gdt]
lgdt [gdtr]
;Now we start by setting the code segment (CS) with a far jump...
jmp 0x08:segment_be_gone
segment_be_gone:
;Now we go ahead and dump our kernel mode data segment (0x10) into the rest of our segments.
;Also preserving eax because it has the bootloader's multiboot magic in it and I want to check it in main.
mov cx, 0x10
mov ds, cx
mov es, cx
mov ss, cx
mov fs, cx
mov gs, cx
;Lets set up the stack. Stack grows downward on x86. We did the work earlier of defining where the top of the stack is, so just tell esp.
mov esp, stack_top ;set the stack pointer
push ebx
@ -105,3 +117,5 @@ section .text
hlt ;Halt!
jmp hang ;just in case...