Hi all , thx for ur time ,
as i told i'm new in OS dev. i've some ques.
1- i want explanation about boot process , i read much about it, but some things i didn't got it yet , like :
when BIOS searches for a bootable sector on a disk and find it , it loads it to 0x7C00 and run it . and then the codes takes the control , right ?? so why we write [org 0x7C00] although this is determined by BIOS. i know that it may be stupid ques. but really that confueses me , plz if any one can explain this area extensivly ( until the loader runs kernel and kernel takes control) i'll be very thankfull.
Help in boot sequence
Re:Help in boot sequence
The BIOS puts you at linear 0x7c00. The code is usually compiled for (note those words) 0x0000:0x7c00 or 0x7c0:0x0000. The first warrants the 0x7c00 (for your compiler/assembler, so he knows where you are) and the second warrants an ORG 0x0000. The first is more common though.tarek wrote: when BIOS searches for a bootable sector on a disk and find it , it loads it to 0x7C00 and run it . and then the codes takes the control , right ?? so why we write [org 0x7C00] although this is determined by BIOS.
Re:Help in boot sequence
Candy is right. To overcome this differnce i.e some BIOS using 0:7c00 while others use 07c0:00,
you can use
[ORG 0x7c00]
.....
.....
....
push cs
pop ds
..........
..........
That would take care of this problem,I have computers with both types of BIOS. Using this method above I managed to get my OS to boot on them all.
In our case of booting an OS, This ORG directive affects how data is accessed using th DS segment cause bios already loads CS with proper segment either 0x0 or 0x07c0.
you can use
[ORG 0x7c00]
.....
.....
....
push cs
pop ds
..........
..........
That would take care of this problem,I have computers with both types of BIOS. Using this method above I managed to get my OS to boot on them all.
In our case of booting an OS, This ORG directive affects how data is accessed using th DS segment cause bios already loads CS with proper segment either 0x0 or 0x07c0.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Help in boot sequence
as long as you don't use absolute near jumps (or calls) -- and they are quite unlikely to happen -- you don't really care what CS contains.
However, you'll like to have access to your datas, and for pmode-enabling stuff, you'll love to have DS == 0. So simply clear DS (and ES if needed) before you access any data and use "ORG 0x7C00" so that the assembler knows the very first byte of your code is targetted at address 0x7C00 in the segment .
However, you'll like to have access to your datas, and for pmode-enabling stuff, you'll love to have DS == 0. So simply clear DS (and ES if needed) before you access any data and use "ORG 0x7C00" so that the assembler knows the very first byte of your code is targetted at address 0x7C00 in the segment .