Page 1 of 1
some booting questions
Posted: Wed Aug 13, 2003 5:54 am
by one
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?
Re:some booting questions
Posted: Wed Aug 13, 2003 6:34 am
by Pype.Clicker
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.
Re:some booting questions
Posted: Wed Aug 13, 2003 12:19 pm
by Tim
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
Posted: Wed Aug 13, 2003 12:50 pm
by HOS
entry:
jmp 0x7C00:.start
i think you want
Re:some booting questions
Posted: Wed Aug 13, 2003 1:33 pm
by Tim
Ahem. You're right.