I'm currently following the Babysteps series and have some questions about the stack.
First, in this tutorial (http://wiki.osdev.org/Babystep4) the stack pointer (sp) is initialized with 0x9c00, leaving the stack at 0000:9c00 and the code at 0x7c00.
So far so good, but then it's said, that the stack starts 0x200 (=512) Bytes past the code.
But since the code is 512 Bytes long (bootloader, ends at 0000:7e00), shouldn't the stack pointer be set to 0x8000? (stack size should be 512 Bytes then).
Am I missing something? And is the stack used by the call instruction? (the tutorial says it is left unused)
Is the following stack setup correct (stack size 512 Bytes).
Code: Select all
start:
; set up data segment
mov ax, 0x07c0
mov ds, ax
; set up stack segment and stack pointer
cli
mov ss, ax
mov sp, 0x400
sti
Do I have to set up the code segment and base pointer as well?
- Lightec