Will the boot-loader code be of any use later on after it loads the secondary/kernel. If not then why do most people say that the bootloader code should be relocated in memory to prevent overwriting?
Any insights on this will be appreciated.Also why does evrybody use a JUMP instruction followed by a NOP at the start of the bootloader? is the NOP required?
some booting questions
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:some booting questions
the NOP is required so that you have 3 bytes of instructions before the Bios Parameters Block (for FAT-compatible organizations)
i'm not sure to know what you refer to when talking of "relocation", but two things are certains:
[*] anything that things it is a bootsector must be loaded at 0x0000:0x7C00, thus if your bootsector needs at a moment to load something else (for instance, a MBR that must defer the boot to the partition's bootsector), it must not stay at 0x0000:0x7C00.
[*] the code you're executing to load the system must not be overwritten before it jump to the code it has loaded.
i'm not sure to know what you refer to when talking of "relocation", but two things are certains:
[*] anything that things it is a bootsector must be loaded at 0x0000:0x7C00, thus if your bootsector needs at a moment to load something else (for instance, a MBR that must defer the boot to the partition's bootsector), it must not stay at 0x0000:0x7C00.
[*] the code you're executing to load the system must not be overwritten before it jump to the code it has loaded.
Re:some booting questions
A small clarification: the BIOS can load the boot sector to any segment:offset pair which evaluates to 0x7C00 linear. Common combinations are 0000:7C00 and 07C0:0000. Therefore you should reload CS, DS and SS at the start to be certain:
Code: Select all
[org 0]
; ...
; ... BPB stuff
; ...
entry:
jmp 0x7C00:.start
.start:
mov ax, cs
mov ds, ax
mov ss, ax
sub sp, sp
Re:some booting questions
i think you wantentry:
jmp 0x7C00:.start
Code: Select all
entry:
jmp 0x07C0:.start