some booting questions

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
one

some booting questions

Post 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?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:some booting questions

Post 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.
Tim

Re:some booting questions

Post 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
HOS

Re:some booting questions

Post by HOS »

entry:
jmp 0x7C00:.start
i think you want

Code: Select all

entry:
    jmp 0x07C0:.start
Tim

Re:some booting questions

Post by Tim »

Ahem. You're right.
Post Reply