`
tianshi_kco
  • 浏览: 21429 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

为什么bios将mbr装载到0x7c00地址,0x7c00怎么来的?

 
阅读更多

Do you know "0x7C00", a magic number, in x86 assembler programming ?
"0x7C00" is the memory address which BIOS loads MBR(Master Boot Record, a first sector in hdd/fdd) into. OS or bootloader developer must assume that their assembler codes are loaded and start from 0x7C00.

But...1st, you may wonder.

"I read all of Intel x86(32bit) programmers manual, but did not found the magic number 0x7C00."

Yes.0x7C00 is NOT related to x86 CPU. It's natural that you couldn't find out it in cpu specifications from intel. Then, you wonder, "Who decided it ?"

2nd, you may wonder:

"0x7C00 is 32KiB - 1024B at decimal number. What's this number means ?"

Anyone decided it. But, why he/she decided such a halfway address?

Hum...There're TWO questions(mysteries) arround the magic number "0x7C00".

  1. Who decided "0x7C00" ?
  2. What "0x7C00 = 32KiB - 1024B" means ?

Okay, let's dive into the secret of BIOS for "IBM PC 5150", ancestor of modern x86(32bit) PCs, with me...!!

"0x7C00" First appeared in IBM PC 5150 ROM BIOS INT 19h handler.

Wandering arround the history of x86 IBM Compatible PC, you know IBM PC 5150 is the ancestor of modern x86(32bit) IBM PC/AT Compatible PCs.
This PC was released at 1981 August, with Intel 8088(16bit) and 16KiB RAM(for minimum memory model). BIOS and Microsoft BASIC was stored in ROM.

When power on, BIOS processes "POST"(Power On Self Test) procedure, and after, call INT 19h.
In INT 19h handler, BIOS checks that PC has any of floppy/hard/fixed diskette or not have.
If PC has any of available diskkete, BIOS loads a first sector(512B) of diskette into 0x7C00.

Now, you understand why you couldn't find out this magic number in x86 documents. This magic number belongs to BIOS specification.

The origin of 0x7C00

Stories surrounding IBM PC DOS, Microsoft, and SCP's 86-DOS are famous stories. See: "A Short History of MS-DOS".

SCP's "86-DOS"(at 1980) is the reference OS for IBM PC DOS 1.0.
86-DOS(early called "QDOS") is CP/M compatible OS for 8086/8088 cpu. At 1979, Digital Research Inc didn't have developed CP/M for 8086/8088 cpu yet.

SCP sold two S-100 bus board, one is 8086 CPU board, two is "CPU Monitor" rom board.
"CPU Monitor" program provided bootloader and debugger. This "CPU Monitor" bootloader loaded MBR into "0x200", NOT "0x7C00". In 1981, IBM PC DOS was the NEXT CP/M like OS for 8086/8088.

So, I told you that "0x7C00 FIRST appeared in IBM PC 5150 ROM BIOS".
Previous one, SCP's CPU Monitor bootloader loads into 0x200, not 0x7C00.

Why that CPU Monitor's bootloader loeded MBR into "0x200" ?

There're THREE reasons about "0x200".

  1. 8086 Interrupts Vector use 0x0 - 0x3FF.
  2. 86-DOS was loaded from 0x400.
  3. 86-DOS didn't use interrupts vectors between 0x200 - 0x3FF.

These reasons mean 0x200 - 0x3FF needed to be reserved and couldn't be in the way of an OS, no matter where 86-DOS or user application wanted to load.

So Tim Paterson (86-DOS developer) chose 0x200 for MBR load address.

Q:Who decided "0x7C00" ? - A: IBM PC 5150 BIOS Developer Team.

"0x7C00" was decided by IBM PC 5150 BIOS developer team (Dr. David Bradley).
As mentioned above, this magic number was born at 1981 and "IBM PC/AT Compat" PC/BIOS vendors did not change this value for BIOS and OS's backward compatibility.

Not Intel(8086/8088 vendor) nor Microsoft(OS vendor) decided it.

Q:What "0x7C00 = 32KiB - 1024B" means ? A: Affected by OS requirements and CPU memory layout.

IBM PC 5150 minimum memory model had only 16KiB RAM. So, you may have a question.

"Could minimum memory model (16KiB) load OS from diskette ? BIOS loads MBR into 32KiB - 1024B address, but physical RAM is not enough..."

No, that case was out of consideration. One of IBM PC 5150 ROM BIOS Developer Team Members, Dr. David Bradley says:

"DOS 1.0 required a minimum of 32KB, so we weren't concerned about attempting a boot in 16KB."

(Note: DOS 1.0 required 16KiB minimum ? or 32KiB ? I couldn't find out which correct. But, at least, in 1981's early BIOS development, they supposed that 32KiB is DOS minimum requirements.)

BIOS developer team decided 0x7C00 because:

  1. They wanted to leave as much room as possible for the OS to load itself within the 32KiB.
  2. 8086/8088 used 0x0 - 0x3FF for interrupts vector, and BIOS data area was after it.
  3. The boot sector was 512 bytes, and stack/data area for boot program needed more 512 bytes.
  4. So, 0x7C00, the last 1024B of 32KiB was chosen.

Once OS loaded and started, boot sector is never used until power reset. So, OS and application can use the last 1024B of 32KiB freely.

After OS loaded, memory layout will be:

+--------------------- 0x0| Interrupts vectors+--------------------- 0x400| BIOS data area+--------------------- 0x5??| OS load area+--------------------- 0x7C00| Boot sector+--------------------- 0x7E00| Boot data/stack+--------------------- 0x7FFF| (not used)+--------------------- (...)

That are the origin and reasons of "0x7C00", the magic number survived for about three decades in PC/AT Compat BIOS INT 19h handler.

References

86-DOS related:

  • "8086 Monitor Instruction Manual"(MON 86 - V1.4)
  • "86-DOS(TM) User's Manual Version 0.3"
  • "86-DOS(TM) Programmer's Manual Version 0.3"
  • "86-DOS(TM) Instruction Manual Version ??"

IBM PC 5150 related:

  • "IBM Personal Computer Hardware Reference Library", "Technical Reference" (IBM Personal Computer Technical Reference manual)
  • "IBM Personal Computer XT Hardware Reference Library", "Technical Reference" (IBM Personal Computer XT Technical Reference manual)

Intel 8086/8088 data sheets:

  • "8086 16-BIT HMOS MICROPROCESSOR"
  • "M80C86/M80C86-2 16-BIT CHMOS MICROPROCESSOR"
  • "8088 8-BIT HMOS MICROPROCESSOR"

CP/M related:

86-DOS related:

And all related Wikipedia pages.

Special Thanks To...

Special Thanks To:

  • Tim Peterson
  • David Bradley
for japanese article, see:
"Assembler/なぜx86ではMBRが"0x7C00"にロードされるのか?(完全版)"
http://www.glamenv-septzen.net/view/614
分享到:
评论

相关推荐

    操作系统高级教程.docx

    对于bios来说,"约定"在接到启动操作系统的命令后,"定位识别"只从启动扇区把代码加载到0x7c00这个位置。后续扇区则由bootsect代码加载,这些代码由编写系统的用户负责,与bios无关。这样构建的好处就是站在整个...

    MBR引导代码分析

    下面这段代码实现把0000:7c1b处MBR代码复制485个字节到0000:061b处,为什么不从0000:7c00开始复制512个到0000:06cc处,因为前面1b 个字节为复制代码,所以忽略.空出的0000:7c00 开始的空间将读入活动分区的操作系统的...

    BIOS、MBR、PBR、分区等基础知识.txt

    BIOS、MBR、PBR、分区等基础知识

    BIOS+MBR硬盘,一步一步教你怎么用clover装黑苹果.doc

    BIOS+MBR硬盘,一步一步教你怎么用clover装黑苹果,教程采用的格式是MBR硬盘格式安装的,采用的电脑是笔记本G510,关闭独显采用核显为HD4600,配置如下:

    MBR病毒分析

    3、 将硬盘第一个扇区(0头0道1扇区,也就是Boot Sector)读入内存地址0000:7c00处; 4、 检查(WORD)0000:7dfe是否等于0xaa55.若不等于则转去尝试其他介质;如果没有其他启动介质,则显示 ”No ROM BASIC” ,然后死机; 5、...

    BIOS、MBR、PBR等基础知识

    BIOS、MBR、PBR等基础知识,兼谈U盘、移动硬盘以及操作系统的安装与启动基本原理.txt

    准系统W650KK/KJ 神舟k670 炫龙dd八代I3bios

    bios by 百度贴吧dsanke 本人闲鱼付费购买,不支持八代i5,仅支持八代奔腾i3 ; ; These settings are not part recommendations, nor are they an ; indication these parts are supported on Intel platforms. ; ...

    下面是一系列蓝屏中可能出现的代码

    1017 0x000003F9 系统尝试将档案加载系统登录或将档案还原到系统登录中,但是,指定档案的格式不是系统登录文件的格式。 1018 0x000003FA 尝试在标示为删除的系统登录机码,执行不合法的操作。 1018 0x000003FA ...

    grub源代码0.95

    (1) BIOS执行INT 0x19,加载MBR至0x7c00并跳转执行。如果你安装GRUB到MBR,GRUB的安装程序会把Stage1(512B)拷贝到MBR。视stage2的大小,安装程序会在Stage1中嵌入Stage1_5或者Stage2的磁盘位置信息。 (2) Stage1...

    操作系统 自己写 详细实现步骤

    然后BIOS跳到地址0x7C00并开始执行相应的程序。正是这个程序负责将操作系统(operating system)读入内存并初始化。 首先来看看引导记录(Boot Record)中有些什么。DOS中的DEBUG是察看内存或磁盘内容的绝好工具。...

    计算机启动过程(1)-BIOS+MBR部分.pdf

    计算机启动过程(1)-BIOS+MBR部分.pdf

    linux操作系统.txt

    1.为什么开始启动计算机的时候,执行的是BIOS代码而不是操作系统自身的代码? 因为CPU的逻辑电路被设计为只能运行内存中的程序,没有能力直接从软盘运行操作系统。...为什么BIOS把bootsect加载到0x07c00,而不是0

    win98硬盘主引导代码反汇编分析.rar_BIOS_bios 反汇编_mbr_rom bios_硬盘引导

    WIN98SE硬盘主引导记录代码反汇编分析硬盘引导记录MBR(Master Boot Record)是指硬盘之0面0道1扇区之内容,PC及其兼容机之ROM BIOS约定在上电及POST自检成功后,将其从硬盘读出,放置在内存0:7C00处,然后转去该...

    系统更新出现代码0x80070002

    一个问题阻止windows正确检查此机器的许可证。错误代码0x80070002

    bootice安装grub2-00 mbr所需要的boot文件夹

    修正: 1.编码问题 2.颜色问题 添加: 1.添加win8pe的菜单到第一项。 使用方法: 用bootice安装grub2到mbr。...pauly兄的bootice最新...step2,将本资源的boot文件夹拷贝到硬盘fat,exfat,ext分区(例如X:),解压到根目录。

    什么是BIOS?如何进入BIOS,恢复BIOS原始设置的快捷方法参考.pdf

    什么是BIOS?如何进入BIOS,恢复BIOS原始设置的快捷方法参考.pdf

    MBR与GPT

    。。

    Linux-0.11 [内核源代码带中文注释]

    bootsect.s 被bios-启动子程序加载至0x7c00 (31k)处,并将自己 ! 移到了地址0x90000 (576k)处,并跳转至那里。 ! ! 它然后使用BIOS 中断将'setup'直接加载到自己的后面(0x90200)(576.5k), ! 并将system 加载到地址...

    XP+0x80070002一个问题阻止WINDOWS正确检查机器许可证.doc

    错误代码:0x80070002,然后重返用户登陆,不能再进入系统。多是打上升级补丁后出现该问题,(一般是你安装了ghost精简系统,然后再安装微软正版升级补丁会出现这样的...xp的正版验证文件是:oembios.bin(路径X:\WI

Global site tag (gtag.js) - Google Analytics