r/osdev • • May 04 '22
the address : 7c00
I have a silly question..
why the origin of boot code is always 7c00.shouldn't it always be FFFF because when we boot our PC all the RAM is free for use then why is this starting at 7c00 ?
12
Upvotes
13
u/[deleted] May 04 '22 edited May 04 '22
When a computer first boots, quite a bit of the ram is not in fact free for use. The bios is loaded in memory and several things like the screen get memory mapped into the address space. The original DOS supported a minimum 32KB of memory so the boot sector got loaded into the highest part of ram that was guaranteed to be available. With more memory now we still use it because it would break things if the location got changed.
Here's a good resource explaining the layout. https://wiki.osdev.org/Memory_Map_(x86)
edit: added reason for location.
11
u/ylli122 SCP/DOS May 04 '22
7C00h was chosen by IBM presumably because their lowest spec IBM PC which supported disk drives and DOS needed at least 32K of system memory. Address 7C00h is one kilobyte below the 32K mark, thus allowing a bootsector to be loaded at 7C00h and a 512 byte stack to be used between 7E00h and 8000h.
Given that context, it makes a lot of sense to have chosen 7C00h as the diskette bootsector load address as it gives a programmer of such a system 30Kb of contiguous memory (address range 400h-7C00h) to use. And considering most BASIC interpreters at the time required contiguous blocks of memory... you can see what I am getting at.
18
u/monocasa May 04 '22
There's several stages of boot code. The boot sector of a disk drive is loaded to 7c00, but the bios itself had been loaded and running for a while at that point. The bios starts at FFFFFFF0 on modern x86.
8
u/Ikkepop May 04 '22
In legacy boot, 7C00 is fixed, you can't change it
but you can always copy your own code somewhere else and jump there
2
u/cybekRT May 05 '22
Most of the RAM is free for use, but not most of the memory map. RAM is only part of the whole memory map. It's been linked below.
The CPU starts at defined at production address, which must contain the BIOS. Then you have to map the video memory, etc. somewhere. That's how the engineers calculated and decided that 0x7C00 is the best location for the bootloaders.