BIOS and Address 0x07C00
Asked Answered
A

1

9

from Wikipedia

On an IBM PC compatible machine, the BIOS selects a boot device, then copies the first sector from the device (which may be a MBR, VBR or any executable code), into physical memory at memory address 0x7C00

I'm reading about the booting process in operating system especially the intel x86 : so what I have found is that BIOS loads the first 512 bytes of the bootloader to the memory location

(segment, offset) = (0x0000,0x7C00) = 0x07C00

and jumps to there to execute the bootloader

my qustion is why BIOS always loads the

bootloader to 0x07C00?

Ambo answered 24/8, 2018 at 0:34 Comment(2)
Possible duplicate of What is significance of memory at 0000:7c00 to booting sequence?Brinson
That's the legacy-BIOS boot method. Modern PCs normally boot in EFI mode, so the first code they load+run that wasn't part of the firmware itself is run in protected mode or 64-bit mode, not in a 16-bit environment that undoes a lot of setup the BIOS did first (for its own internal 64-bit code). See wiki.osdev.org/UEFI. Modern PCs do still have a legacy boot mode, so you can boot legacy BIOS boot sectors, but learning about it is becoming less and less relevant. (except maybe as a learning exercise once you already know some asm in general).Investigator
T
11

The reason why BIOS always loads the bootloader to 0x07C00 is historical.

In the early days, a PC is only guaranteed to have 64 KB of RAM memory.

The memory below 0x07C00 is reserved for interrupt vectors, BIOS and BASIC, etc.

The first OS usable memory begins at 0x08000.

So the bootloader is loaded to 0x07C00, which is 1 KB below 0x08000.

Tandratandy answered 24/8, 2018 at 0:37 Comment(4)
thank you , can you told me how to write such bootloaders?Ambo
@Ambo try the best free resource out there osdevTandratandy
Having been around the PC'sfor many decades, the 0x7c00 choice is generally considered to be a combination of the IBM 5150 that had the capacity to use 16kb and 32kb. The first version of DOS came out with a specification of at least 32kb of memory. At the time the BIOS designers chose 0x7c00 to read the boot sector into. 0x7c00 to 0x7dff. The first BIOSes usually placed the stack growing down from 0x8000 towards the bootloader. This default stack area was needed for the BIOS routines (interrupts service routines etc, BIOS call) to function properly.Araiza
That left pretty much everything below 0x7c00 for the rest of the OS and applications. 64kb machines became the typical low end configuration but the 0x7c00 was never changed.Araiza

© 2022 - 2024 — McMap. All rights reserved.