From 9a30df58affaa1c00ebdc77693ffe6004e507230 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 11 Nov 2025 00:02:58 -0500 Subject: mbr: Transfer to C in protected mode Signed-off-by: Ian Moffett --- mbr/stage1.asm | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'mbr/stage1.asm') diff --git a/mbr/stage1.asm b/mbr/stage1.asm index ea51f22..d0299e4 100644 --- a/mbr/stage1.asm +++ b/mbr/stage1.asm @@ -17,9 +17,39 @@ _start: call enable_a20 call disk_load - jmp 0x0000:0x8000 - hlt - jmp $ + ;; Enable protected mode + mov eax, cr0 + or al, 1 + mov cr0, eax + + lgdt [GDTR] + jmp 0x8:0x8000 + +GDT32: +.null_desc: + dw 0x0000 + dw 0x0000 + db 0x00 + db 0b00000000 + db 0b00000000 + db 0x00 +.code_desc: + dw 0xFFFF + dw 0x0000 + db 0x00 + db 0b10011010 + db 0b11001111 + db 0x00 +.data_desc: + dw 0xFFFF + dw 0x0000 + db 0x00 + db 0b10010010 + db 0b11001111 + db 0x00 +GDTR: + dw $ - GDT32 - 1 + dd GDT32 ;; ;; Write a string to the screen -- cgit v1.2.3