[SOLVED] Bootloader Problem
Posted: Sat Jul 26, 2008 2:11 pm
I'm trying to make a bootloader and I'm running into a little trouble with loading the kernel into memory and then jumping to it. I believe I've figured out how to read the disk, just not where to read it to and then how to jump to it.
Is there anything the bootloader needs to do other than load and then jump to the kernel? Such as enter protected mode or enable A20? All mine does is switch the screen mode and draw a pixel. Here is my code for the bootloader so far:
I'm unsure what I should place in ES and BX when loading the kernel (the '????'s) Everything I have tried has given me errors such as prefetch: EIP [00010000] > CS.limit [0000ffff]
If anyone can't tell, I'm new to this, so I was also wondering where people figured out what they had to do to make an OS, other than tutorials. I've followed some tutorials on making kernels, but I feel that I don't actually learn very much from them. For example: what is a GDT, why do you need it, how you know it's implemented properly, its structure, etc.
Thanks.
Is there anything the bootloader needs to do other than load and then jump to the kernel? Such as enter protected mode or enable A20? All mine does is switch the screen mode and draw a pixel. Here is my code for the bootloader so far:
Code: Select all
BITS 16
ORG 7C00h ;BIOS jumps to 7C00
JMP short START
START:
;**********Switch Screen Mode**********
;switch to screen mode 13
MOV AH, 00h ;set interrupt 10h to change screen mode
MOV AL, 13h ;screen mode 13
INT 10h ;switch the mode
;**********Switch Screen Mode**********
;**********Draw Pixel**********
MOV DX, 0A000h ;move screen address into data register
MOV ES, DX ;move screen address from data register for STOSB
MOV DI, 0F9FFh ;set drawing offset
MOV AL, 10 ;select the color of the pixel
STOSB ;transfer byte from register AL to ES:DI
;**********Draw Pixels**********
MOV BX, ????
MOV ES, BX
MOV BX, ????
MOV AH, 02 ;read sectors into memory
MOV AL, 17 ;read 17 sectors
MOV CH, 00 ;track 0
MOV CL, 02 ;sector 2
MOV DH, 01 ;head number 1
MOV DL, 00 ;drive number 0
INT 13h
JMP ????
LOOP: JMP LOOP ;endless loop
TIMES 0200h - 2 - ($ - $$) DB 0 ;fill all but last two bytes of first sector
DW 0AA55h ;last two bytes myst be 0xAA and 0x55 inorder to be bootable
If anyone can't tell, I'm new to this, so I was also wondering where people figured out what they had to do to make an OS, other than tutorials. I've followed some tutorials on making kernels, but I feel that I don't actually learn very much from them. For example: what is a GDT, why do you need it, how you know it's implemented properly, its structure, etc.
Thanks.