title: Intel Stack Growth and Reference
body: <p>I have a couple of questions regarding the Intel IA-32 stack. Specifically:</p>
  
  <ol>
  <li>When I <code>push</code> a value onto the stack, the stack pointer is decreased by the size of the value pushed (<code>%esp - size</code>), and the value is stored at the old value of <code>%esp</code>.</li>
  <li>If I then want to read the value back off of the stack without <code>pop</code>ing it, I need to increase the stack pointer (<code>%esp + size</code>).</li>
  <li><a href="https://github.com/Andromeda-OS/Kernel/blob/master/osfmk/x86_64/idt64.s#L169" rel="nofollow">A piece of kernel code I have</a> is subtracting the size needed from the stack, instead of adding it. It is my assumption that when this happens, the value I want is moving <em>away</em> from the pointer address, instead of <em>towards</em> it.</li>
  <li>Because of this, any further read will pick up bad data.</li>
  </ol>
  
  <p>Are my above assertions correct? Thanks in advance.</p>