title: Would 0x0900 be a good value for the stack segment?
body: <p>I'm writing a tiny kernel for educational purposes and I was thinking of a good way to set up my stack in real-mode.
  I read from here: <a href="http://wiki.osdev.org/Memory_Map_%28x86%29" rel="nofollow">http://wiki.osdev.org/Memory_Map_%28x86%29</a> that addresses <em>0x07E00</em> to <em>0x7FFFF</em> were guaranteed to be free for use.</p>
  
  <p>So if I set the stack segment to <em>0x0900</em>, that would give the stack a range from <em>0x0900 &lt;&lt; 4</em> to <em>0x0900 &lt;&lt; 4 + 0xFFFF</em> which is <em>0x09000</em> to <em>0x18FFF</em> which means I would get a safe <em>0x10000</em> bytes of stack space, right?</p>
  
  <p>And I could just set my stack pointer to 0, and it would "underflow" to 0xFFFE at the next push too? Segmentation is a little confusing to me.</p>
  
  <p>This is how the relevant part of the code looks:</p>
  
  <pre><code>BITS 16
  ORG 0x0000
  
  mov ax, 0x07C0
  mov ds, ax          ; ds = origin of code
  
  mov ax, 0xB800
  mov es, ax          ; es = origin of video memory
  
  mov ax, 0x0900
  mov ss, ax
  
  mov ax, 0
  mov sp, ax
  </code></pre>