From 071a6d2c84d8c8a3557ab038b5795f4401f20838 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 16 Jun 2017 14:50:58 +0200 Subject: fixed the stack position to 0x2000, not 0xFFFF in real mode! zeroing all general purpose registers after switching to protected mode --- src/boot/boot.asm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/boot') diff --git a/src/boot/boot.asm b/src/boot/boot.asm index 75ad05e..0f31c9d 100644 --- a/src/boot/boot.asm +++ b/src/boot/boot.asm @@ -22,8 +22,11 @@ ; make sure we know the location of the stack by setting it on our own ; this stack is only used in real mode in stage 1, so it's growing from -; 0xffff down - mov bp, 0xFFFF +; 0x2000 down, we should really not set it above 0x7c00, as this is +; exacly the place, where we load stage 2 and the kernel to! (was 0xffff, +; which was a really bad idea after the kernel got bigger than roughly +; 32k!) + mov bp, 0x2000 mov sp, bp ; print out some information about CPU mode and BIOS boot drive @@ -170,6 +173,13 @@ MESSAGE_HALTED_REAL: [bits 32] BEGIN_PROTECTED_MODE: +; make sure registers have known values + xor eax, eax + xor ebx, ebx + xor ecx, ecx + xor edx, edx + xor esi, esi + xor edi, edi ; we switched to protected mode mov si, MESSAGE_PROTECTED_MODE -- cgit v1.2.3-54-g00ecf