Bootloader 0x7C00

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
skandalOS
Posts: 15
Joined: Mon Sep 05, 2011 12:05 pm

Bootloader 0x7C00

Post by skandalOS »

Hello,

I've got a specific question about bootloader which I couldn't answer after googling or reading some
papers.

I know that it is a convention that the bootloader has to be loaded starting by adress 0x7C00 (31744), but
why exactly at this adress?

On Real mode: Registers operates with 16 bits, which may contain maximum 0xFFFF.
0xFFFF - 0x7C00 = 1 Kb, which leads me thinking that a bootloader can maximum have 1kb memory.
But, as well as i know that bootloader must have 512 byte. So, why this remainded 512 byte block(1kb - 512 byte) ?

So. why actually 0x7C00 ? convention ? but why?

thnx before
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Bootloader 0x7C00

Post by gerryg400 »

0xFFFF - 0x7C00
equals 0x83FF
If a trainstation is where trains stop, what is a workstation ?
skandalOS
Posts: 15
Joined: Mon Sep 05, 2011 12:05 pm

Re: Bootloader 0x7C00

Post by skandalOS »

ohh sorry, it was a mistake of me, because I assumed that 2^16 is 32768 instead of 65536.

But can I anybody give an answer why 0x7C00? and what is before (0-7bff)?

thanx
GReaper
Posts: 4
Joined: Sun Sep 11, 2011 7:59 pm

Re: Bootloader 0x7C00

Post by GReaper »

skandalOS wrote:But can I anybody give an answer why 0x7C00? and what is before (0-7bff)?
You said convertion, I'd say tradition. Besides, below this address there is the possibility you'll run onto system reserved memory like memory-mapped hardware, important system data structures etc.
User avatar
mark3094
Member
Member
Posts: 164
Joined: Mon Feb 14, 2011 10:32 pm
Location: Australia
Contact:

Re: Bootloader 0x7C00

Post by mark3094 »

skandalOS wrote:what is before (0-7bff)?
Have a look at the large table o this page (about 1/3 of the way down):
http://www.brokenthorn.com/Resources/OSDev7.html

skandalOS wrote:why 0x7C00?
Because it has to be somewhere... :D
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Bootloader 0x7C00

Post by Solar »

skandalOS wrote:0xFFFF - 0x7C00 = 1 Kb, which leads me thinking that a bootloader can maximum have 1kb memory.
A bootloader has to fit into the MBR, and thus may be no larger than 446 bytes.
Every good solution is obvious once you've found it.
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Bootloader 0x7C00

Post by Chandra »

mark3094 wrote:
skandalOS wrote:why 0x7C00?
Because it has to be somewhere... :D
=D>
skandalOS wrote:But, as well as i know that bootloader must have 512 byte.
Actually it can be of size 512 bytes(fd,hd,sd) or 2048 bytes(cd).
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: Bootloader 0x7C00

Post by turdus »

It cames from the IBM PC design, originally it was (in the XT era):
0-400h IVT
400h-500h BIOS area
500h-600h BIOS BASIC area
600h-7C00h boot loader memory (stack)
7C00h-7E00h place where the MBR code loaded (8000h-2 sector)
7E00h-8000h place where the VBR code loaded (8000h-1 sector)
8000h - first OS usable memory

As it turned out it was a bad design, MSDOS used 7C00h for VBR code as well, relocating the MBR to 600h. Using the same address gives the ability to chainload different loaders regardless of their type (MBR or VBR), so 7E00h left out pretty soon, 7C00h remains as a tradition (and it was impossible to change BIOS ROM in machines already shipped).
CelestialMechanic
Member
Member
Posts: 52
Joined: Mon Oct 11, 2010 11:37 pm
Location: Milwaukee, Wisconsin

Re: Bootloader 0x7C00

Post by CelestialMechanic »

This is my guess as to why the address 0x7C00 was chosen for loading the boot sector. Please note that I have never worked for IBM or Microsoft, this is just my inference from the state of the art at that time (1981).

The IBM PC was originally sold in configurations with 16, 64 and (I think) 32 kilobytes of RAM. (Yes! Kilobytes!) The original IBM PC came with BASIC on ROM, just like many of the home computers of that time, so the 16K configuration was just fine for a little BASIC, and maybe loading and saving short files from a cassette tape recorder. (Remember casette tapes? Our younger readers may want to ask their parents what saving and loading to cassette tape was like.)

32K seemed to be the logical minimum for loading an operating system from a floppy disk drive, so the load address for that boot sector was placed just before 0x8000 as a least common denominator location. (The original version of PC-DOS 1.0 used about 9K, if memory serves.)

A popular format for floppy disks of that time was called IBM Format 34, which allowed for sector sizes of 128, 256, 512, or 1024 bytes. Loading the sector at 0x8000 - 1024 = 0x7C00 (sorry for the mixed bases) meant that a boot sector of any size could be used no matter what sector size finally won out. Of course requiring the signature at 0x1FE tended to rule out the smaller sizes, and would have created a difficulty (though not insurmountable) for 1024 byte sectors.

Remember, this is an educated guess. It is only an educated guess. And now back to regular programming ...
Microsoft is over if you want it.
Post Reply