What Happens When You Press Power? Unraveling the BIOS Boot Process
This article demystifies the computer startup sequence by explaining why BIOS controls the initial boot, how memory mapping and real-mode address space work, the role of the 0x7C00 loading address, and what the boot sector code actually does.
The author, known as 闪客sun, writes in‑depth technical articles that are suitable for careful reading.
What actually happens when we press the power button?
Many people wonder why a seemingly simple question is hard to answer directly. The main reasons are that many explanations are vague textbook descriptions, and experts either do not answer or give overly brief replies.
Reason One , many people only have a superficial understanding and repeat textbook phrases.
Reason Two , those who truly know the answer are often senior engineers who either do not respond or give overly concise answers.
Typical descriptions say that the BIOS follows the "boot order" to hand control to the first storage device, loads the master boot record into memory, and then the operating system starts. This description is vague, so we will explain it clearly.
Before learning the boot process, you need three pieces of prerequisite knowledge:
Memory stores data and can return the data at a given address.
The CPU repeatedly fetches instructions from memory and executes them.
The address from which the CPU fetches the next instruction is held in a register that increments or can be set by a jump instruction.
With these prerequisites, we can explain the computer startup process.
1. Why does BIOS dominate?
After power‑on, the BIOS runs its own program, performs hardware self‑test, and loads the boot sector. This is because the CPU fetches instructions from memory, and the BIOS code is placed at a known memory‑mapped address.
2. Memory Mapping
The width of the CPU address bus determines the size of the addressable memory space (e.g., a 32‑bit bus can address 4 GB). Not all addressable space is used for RAM; parts are reserved for peripherals such as video memory and disk controllers. These peripheral regions are mapped into specific memory address ranges, a technique called memory mapping .
3. Real‑mode Memory Layout
In real mode, the first 1 MB of address space is divided among RAM and mapped peripherals. The BIOS itself occupies the region 0xC0000‑0xFFFFF, and the interrupt vector table resides at the very beginning of memory.
4. How does execution start from BIOS?
The BIOS entry point is at physical address 0xFFFF0. When the power button is pressed, the CPU’s PC register is forced to 0xFFFF0, causing execution to begin there.
In real mode, the segment register CS is set to 0xF000 and the offset IP to 0xFFF0, which together form the physical address 0xFFFF0.
5. What does BIOS actually contain?
At 0xFFFF0 the BIOS stores a jump instruction that redirects execution to a larger code area, typically at 0xFE05B: jmp far f000:e05b This code performs hardware detection, initializes devices, builds the interrupt vector table, and finally loads the boot sector.
6. What is 0x7C00?
The BIOS copies the 512‑byte boot sector from the first sector of the selected boot device into memory at address 0x7C00 and then jumps to that address.
The boot sector must end with the signature bytes 0x55 and 0xAA; otherwise the BIOS ignores it.
7. What does the boot sector code contain?
The boot sector typically contains a small assembly program that sets up segment registers, prints a message, and then halts. An example from "30 Days to Build an OS" is:
; hello‑os
ORG 0x7c00
entry:
MOV AX,0
MOV SS,AX
MOV SP,0x7c00
MOV DS,AX
MOV ES,AX
MOV SI,msg
putloop:
MOV AL,[SI]
ADD SI,1
CMP AL,0
JE fin
MOV AH,0x0e
MOV BX,15
INT 0x10
JMP putloop
fin:
HLT
JMP fin
msg:
DB 0x0a,0x0a
DB "hello‑os"
DB 0x0a
DB 0
RESB 0x7dfe-$
DB 0x55,0xaaThe directive ORG 0x7c00 tells the assembler that the code will be loaded at address 0x7C00.
8. What does the OS kernel contain?
After the BIOS loads the boot sector and transfers control to it, the boot sector loads the rest of the operating system kernel into memory and jumps to it. From there, the kernel performs tasks such as segmentation, paging, interrupt handling, device drivers, memory management, process management, file systems, and user‑mode interfaces.
9. References
For deeper study, the author recommends the books "30 Days to Build an OS" and "Operating System: Reconstructed".
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Python Crawling & Data Mining
Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
