Aprelius logo
uptime: 00:00:00
Computer Science

ROM and CPU Interaction

The CPU and ROM work together during system startup and operation. ROM holds the permanent instructions the CPU needs to initialize hardware and boot the system.

What is ROM?

ROM (Read-Only Memory) is non-volatile storage that retains data even when power is off. It typically contains:

  • BIOS/UEFI firmware: Basic Input/Output System or Unified Extensible Firmware Interface
  • Boot instructions: initial code to start the computer
  • Hardware initialization routines: code to configure system components

How CPU accesses ROM

The CPU talks to ROM through the system bus, which consists of:

text
CPU ←→ Address Bus ←→ ROM
    ←→ Data Bus    ←→
    ←→ Control Bus ←→
  • Address Bus: CPU sends memory addresses to specify which ROM location to read
  • Data Bus: ROM sends instruction/data bytes back to the CPU
  • Control Bus: signals for read/write operations and timing

Boot process (Power-On)

Key concepts

Fetch-Execute Cycle

text
1. FETCH: CPU reads instruction from ROM address
2. DECODE: CPU interprets the instruction
3. EXECUTE: CPU performs the operation
4. Repeat with next address

Memory Mapping: ROM is mapped to specific address ranges in the CPU's memory space. For example:

  • x86 legacy BIOS: 0xF0000 to 0xFFFFF (last 64KB of the 1MB real-mode space)
  • Modern UEFI: firmware is typically shadowed into RAM or not mapped in the low 1MB at all
  • ARM systems: various addresses depending on architecture

ROM Shadowing: ROM (especially flash) is slow compared to RAM. Early in the boot process, the firmware copies itself from ROM into fast RAM ("shadow RAM") and maps that same address range read-only, so subsequent accesses hit RAM instead of ROM. This means the CPU only fetches its first instructions directly from ROM — the rest of the boot runs from shadowed RAM.

Why ROM for boot?

  • RAM is volatile (loses data when powered off)
  • CPU needs immediate instructions at power-on
  • ROM provides reliable, unchanging boot code

Modern systems

Today's systems often use flash memory instead of traditional ROM:

  • Still non-volatile like ROM
  • Can be updated (firmware updates)
  • Functions the same way during boot