diff --git a/src/start.s b/src/start.s index 702df0b..8823c6e 100644 --- a/src/start.s +++ b/src/start.s @@ -90,9 +90,21 @@ 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 - ;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. + + 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 push eax @@ -105,3 +117,5 @@ section .text hlt ;Halt! jmp hang ;just in case... + +