Jumat, 21 Februari 2014

Bootsector

Requirements
============
During this article I assume that you have good knowledge of the assembly language and intel architecture. If not, read an assembly tutorial, they aren't hard to find...

Start
=====

Creating your own bootsector is simpler than you may think, the only requirement is that the bootsector is 512 bytes long, and at offset 0x1FE (decimal=510), the word 0xAA55 is placed. This is the first thing the BIOS does when the PC boots up, it first looks on the first floppy drive at the first sector for 0xAA55 at the end, and if it finds it then it loads it into memory, and starts executing it, otherwise it trys the primary harddisk, and if that isn't found it just bombs out with an error.



You should place your boot sector at:
            Sector 1
            Cylinder 0
            Head 0

I recommend you start playing about with floppys first instead of your hard disk
because the hard disk bootsector stores information about the file system if you
are running DOS/Windows, if you overrite that, then you have just lost your
hard disk contents :-)

The BIOS loads the bootsector at linear offset 0x7C00, the state of the registers are:

      DL = Boot drive, 1h = floppy1, 80h = primary harddisk, etc
      CS = 0
      IP = 0x7c00

So instead of adding [ORG 7C00h] to the top of your file, you can add:

mov ax, 0x7C0
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax

And that will set-up the segment registers so they point to the start of your bootsector..

Most boot sectors usually just store the boot drive, load the kernel  from disk, and jump to it.. Some will also load protected mode.

  -=- authoring by Gareth Owen gaz@athene.co.uk -=-

Tidak ada komentar:

Posting Komentar