They're calling him "mr has a working custom GDT"
... ... ...I'm sorry they don't call me that.
This commit is contained in:
parent
b127a659bb
commit
8fadee6baf
1 changed files with 16 additions and 2 deletions
16
src/start.s
16
src/start.s
|
|
@ -90,8 +90,20 @@ section .text
|
||||||
;Here it is!
|
;Here it is!
|
||||||
start:
|
start:
|
||||||
;We made a GDT! Let's use it!
|
;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.
|
;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
|
mov esp, stack_top ;set the stack pointer
|
||||||
push ebx
|
push ebx
|
||||||
|
|
@ -105,3 +117,5 @@ section .text
|
||||||
hlt ;Halt!
|
hlt ;Halt!
|
||||||
jmp hang ;just in case...
|
jmp hang ;just in case...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue