title: How does compiler lay out code in memory
body: <p>Ok I have a bit of a noob student question.</p>
  
  <p>So I'm familiar with the fact that stacks contain subroutine calls, and heaps contain variable length data structures, and global static variables are assigned to permanant memory locations. </p>
  
  <p>But how does it all work on a less theoretical level?</p>
  
  <p>Does the compiler just assume it's got an entire memory region to itself from address 0 to address infinity? And then just start assigning stuff?</p>
  
  <p>And where does it layout the instructions, stack, and heap?  At the top of the memory region, end of memory region?</p>
  
  <p>And how does this then work with virtual memory?  The virtual memory is transparent to the program?</p>
  
  <p>Sorry for a bajilion questions but I'm taking programming language structures and it keeps referring to these regions and I want to understand them on a more practical level.</p>
  
  <p>THANKS much in advance!</p>