title: how can a label in assembly know its runtime address?
body: <p>I am learning assembly (z80 and x86) and am now coming to grips with building binaries using an assembler.</p>
  
  <p>How is it possible to use labels with absolute (as opposed to relative) addresses?</p>
  
  <p>From what I understand, an assembler will translate a label to a memory address on compilation, but <strong>how is it possible for the assembler to know which address a label will reside in at runtime</strong>?</p>
  
  <p>It seems simple enough for a z80 bare metal system, as you can load a program into a specific memory address and send an <code>RST</code> signal that will point the program counter to <code>0000h</code>. <strong>What happens when there is an operating system running</strong>?</p>
  
  <p>Wouldn't code executed within an operating system not know its starting address (and thereby have no way of using non-relative opcodes like <code>call</code> and <code>ret</code> on labels)?</p>