Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You don't have a choice here. Read this article:</p> <p><a href="http://en.wikibooks.org/wiki/X86_Assembly/Bootloaders" rel="nofollow">http://en.wikibooks.org/wiki/X86_Assembly/Bootloaders</a></p> <p>From the above URL, BIOS (which is effectively PC hardware) will make the jump to memory at 0000:7c00 to continue execution in 16-bit mode.</p> <p>And to quote from above:</p> <blockquote> <p>A bootloader runs under certain conditions that the programmer must appreciate in order to make a successful bootloader. The following pertains to bootloaders initiated by the PC BIOS: </p> <ul> <li>The first sector of a drive contains its boot loader. </li> <li>One sector is 512 bytes — the last two bytes of which must be 0xAA55 (i.e. 0x55 followed by 0xAA), or else the BIOS will treat the drive as unbootable. </li> <li>If everything is in order, said first sector will be placed at RAM address 0000:7C00, and the BIOS's role is over as it transfers control to 0000:7C00. (I.e. it JMPs to that address)</li> </ul> </blockquote> <p>So from bootup, if u want the CPU to start executing your code, it has to be located in memory at 0000:7c00. And this part of the code is loaded from the first sector the harddisk - also done by hardware. And it is only the first sector which is loaded, the remaining of other parts of the code then have to be loaded by this initial "bootloader".</p> <p>More information here (on harddisk bootup sector and the 7c00 feature):</p> <p><a href="http://www.ata-atapi.com/hiwdos.html" rel="nofollow">http://www.ata-atapi.com/hiwdos.html</a></p> <p><a href="http://www.ata-atapi.com/hiwmbr.html" rel="nofollow">http://www.ata-atapi.com/hiwmbr.html</a></p> <p>Please don't confuse with the starting up mode of the CPU - the first instruction it will fetch and execute is at physical address 0xfffffff0 (see page 9-5):</p> <p><a href="http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.pdf" rel="nofollow">http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-vol-3a-part-1-manual.pdf</a></p> <p>and at this stage it is executing non-volatile (meaning you cannot reprogram it easily, and thus not part of bootloader's responsibility) BIOS code.</p> <p><strong>Update: 6 Oct 2015</strong></p> <p>But this BIOS code does have some variation (as highlighted by Michael Petch) - some BIOS will load from 07c0:0000 instead of 0000:7c00, and as extracted from "grub" bootloader source code as well:</p> <pre><code>.globl _start; _start: /* * _start is loaded at 0x7c00 and is jumped to with CS:IP 0:0x7c00 */ /* * Beginning of the sector is compatible with the FAT/HPFS BIOS * parameter block. */ jmp after_BPB nop /* do I care about this ??? */ after_BPB: /* general setup */ cli /* we're not safe here! */ boot_drive_check: jmp 1f testb $0x80, %dl jnz 1f movb $0x80, %dl 1: /* * ljmp to the next instruction because some bogus BIOSes * jump to 07C0:0000 instead of 0000:7C00. */ ljmp $0, $ABS(real_start) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload