title: Bootloader stack configuration
body: <p>the following is the start of the code for the educational real
  mode x86 operating system MikeOs. (mikeos.sourceforge.net) As I understand it
  the x86 stack grows 'down' that is towards low memory, and the stack segment
  register ss points to the lowest possible memory location in the stack segment (offset 0).
  So, the question is, why is it necessary to add 4096bytes to the code segment in
  order to create a 4K stack? Should it not be sufficient to add 512 bytes to 
  the code segment and store that in the ss stack segment, since the boot sector
  may only be 512 bytes long?</p>
  
  <pre><code> BITS 16
  
   start:
    mov ax, 07C0h   ; Set up 4K stack space after this bootloader
    add ax, 288     ; (4096 + 512) / 16 bytes per paragraph
    mov ss, ax
    mov sp, 4096
    mov ax, 07C0h   ; Set data segment to where we're loaded
    mov ds, ax
  </code></pre>