It both directly executes from ROM and copies stuff into RAM.
On a modern x86 processor, the chipset memory controller is uninitialized at initial power-up, so there is no RAM available.
A modern BIOS is usually divided into two parts:
- Boot Block (early POST)
- Compressed Area (mid-to-late POST)
When the processor comes out of reset, it begins executing instructions at a fixed address in memory, called the "reset vector". The BIOS flash chip is mapped to this address in memory. The processor simply starts executing instructions from this address.
The "Boot Block" refers to the BIOS code starting at the reset vector (plus a few JMPs). This is executed directly from ROM (memory controller isn't up yet), so it is very slow.
The BIOS Boot Block generally does the following:
- Initialize the memory controller. (If you get a "memory not detected" beep code from a motherboard, it happens here.)
- Perform a checksum on the Compressed Area to make sure the rest of the BIOS is free of corruption.
- Jump into a Recovery Mode if any corruption is detected.
- If the checksum passes, decompress the rest of the BIOS into RAM somewhere (typically below the 1MB boundary).
- Jump to the decompressed code in RAM and continue with boot.