title: How can early BIOS use CALL?
body: <p>I am, purely for hobby reasons, trying to understand some low-level code in the PC. I downloaded an outdated BIOS ROM image for a random old Gigabyte MB (<a href="https://www.gigabyte.com/Motherboard/GA-8I845GE775-G-rev-10/support#support-dl-bios" rel="nofollow noreferrer">https://www.gigabyte.com/Motherboard/GA-8I845GE775-G-rev-10/support#support-dl-bios</a>), it's almost 15 years old so I hope it doesn't harm anyone's IP rights. I'll be using this file for reference.</p>
  
  <p>I'm stumbled right at the beginning. These seem to be the very first instructions the processor sees after power up:</p>
  
  <pre><code>f000:fff0  ljmp 0xf000:0xe05b
  f000:e05b  jmp 0xf46c
  f000:f46c  cli
  f000:f46d  cld
  f000:f470  smsw ax       ; read CR0
  f000:f473  test al, 1    ; test Protected Mode Enable
  f000:f475  je 0xf480
  [assuming PE is zero – jump:]
  f000:f480  jmp 0xe043
  f000:e043  mov al, 0x8f
  f000:e045  out 0x70, al  ; CMOS controller: disable NMI, set index 0xf
  f000:e047  out 0xeb, al  ; this port is presumably unoccupied: just a delay mechanism
  f000:e049  in al, 0x71   ; read 0xf (CMOS Shutdown Status)
  f000:e04b  out 0xeb, al  ; more delay
  f000:e04d  or al, al
  f000:e04f  jmp 0xf483
  f000:f483  jne 0xf488
  [assuming status = 0 (Power on or soft reset) – pass:]
  f000:f485  call 0x4dee
  </code></pre>
  
  <p>Assuming the CMOS shutdown status is zero upon powering the computer on, the BIOS issues a call at <code>f000:f485</code>. At that early moment, no attempt would have been done at detecting whether any RAM is even present. The stack segment and stack pointer have not been set up, either. The code at <code>f000:f485</code> indeed looks like a function and ends with a <code>ret</code>. How is this possible, where does the <code>call</code> store the return address?</p>
  
  <p>Or am I misunderstanding the values returned from port <code>0x71</code>? I used these two documents for reference:</p>
  
  <p>The meaning of writing <code>0x8f</code> to <code>0x70</code>: <a href="https://wiki.osdev.org/CMOS#CMOS_Registers" rel="nofollow noreferrer">https://wiki.osdev.org/CMOS#CMOS_Registers</a></p>
  
  <p>The meaning of the values subsequently read from <code>0x71</code>: <a href="http://www.bioscentral.com/misc/cmosmap.htm" rel="nofollow noreferrer">http://www.bioscentral.com/misc/cmosmap.htm</a></p>