Turn: Source
Http://www.ruanyifeng.com/blog/2015/09/0x7c00.html
The computer principles textbook says that the master boot record is stored in memory address 0x7c00 at startup.
This strange address, how to come, the textbook will not explain. I have always wondered, why not put in the memory of the head, tail, or other location, and just deposit this 1024 bytes smaller than 32KB place?
Yesterday, I read an article, finally solved the mystery.
First of all, if you don't know what the Master boot record (Master boot record, abbreviated as MBR) is, you can read first how does the computer start? 》。
Simply put, computer startup is such a process.
- Power
- Read the BIOS inside the ROM to check the hardware
- Hardware check through
- The BIOS checks the first sector of the boot device (that is, the master boot record) according to the specified order, loading the memory address 0x7c00
- Master boot Record give operation right to operating system
Therefore, the master boot Record is a small program that directs the "operating system" into memory, with a size of no more than 1 sectors (512 bytes).
0X7C00 This address comes from Intel's first-generation PC chip 8088, which is used by future CPUs to stay compliant.
IBM's first PC, IBM PC 5150, went public in August 1981, using the chip.
At that time, the operating system was 86-dos. The minimum memory required for this operating system is 32KB. We know that the memory address is numbered from 0x0000, and 32KB of memory is 0x0000~0x7FFF
.
8088 the chip itself needs to be occupied to 0x0000~0x03FF
save the various interrupt handlers stored in the location. (The master boot record itself is a handler for interrupt signal int 19h.) So, memory is only 0x0400~0x7FFF
available for use.
to leave as much contiguous memory as possible to the operating system, the master boot record is placed at the tail end of the memory address. since a sector is 512 bytes, the master boot record itself produces data that requires an additional 512 bytes to be saved. So, its reserved position becomes:
0x7FFF-512-512+1=0x7C00
That's how 0x7c00 came.
After the computer starts, 32KB memory is used as follows.
+--------------------- 0x0
|Interrupts vectors
+--------------------- 0x400
|BIOS Data area
+--------------------- 0x5??
|OS Load Area
+--------------------- 0x7c00
|Boot sector
+--------------------- 0x7e00
|Boot data/Stack
+--------------------- 0x7FFF
| (Not used)
+--------------------- (...)
Finish
Why is the memory address of the master boot record 0x7c00?