Welcome to Dream.In.Code
Become an Expert!

Join 149,504 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,359 people online right now. Registration is fast and FREE... Join Now!




bootloader

 
Reply to this topicStart new topic

bootloader

Apples
27 Sep, 2007 - 04:16 PM
Post #1

New D.I.C Head
*

Joined: 15 Nov, 2006
Posts: 21


My Contributions
I am interested in creating a bootloader for the x86 CPU. I already know assembly and a bit about how the processor works..but I don't know where to start. Any information would be appreciated. biggrin.gif
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Bootloader
27 Sep, 2007 - 09:27 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,655



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
You might want to check out the following site which outlines the process and provides examples of building a bootloader using assembly.

Enjoy!

Hello world bootloader development tutorial
User is offlineProfile CardPM
+Quote Post

Apples
RE: Bootloader
4 Oct, 2007 - 06:44 PM
Post #3

New D.I.C Head
*

Joined: 15 Nov, 2006
Posts: 21


My Contributions
alright..so i took a look at those tutorials, and i wrote a bootloader that is -supposed- to clear the screen and print a line..i took a lot of the code from the tutorial but it's not working [for some reason]. it worked before i wrote the clear screen function too, if that helps in debugging it.

CODE

[BITS 16]        ;Tells the assembler that its a 16 bit code
[ORG 0x7C00]        ;Origin, tell the assembler that where the code will
                    ;be in memory after it is been loaded

CALL ClearScreen
MOV SI, setA20      ;Store string pointer to SI
CALL PrintString      ;Call print string procedure
JMP $                   ;Infinite loop

ClearScreen:
  XOR AL, AL        ;Set AL to 0
    MOV AH, 0x06      ;Function 06 of int 10h [scroll window up, if al = 0 clrscr]
    MOV CX, 0x00      ;Clear from 0,0
    MOV DX, 0x174f      ;To 23,79
    MOV BH, 0x00        ;Background color
    INT 0x10          ;Call video interrupt
RET

PrintCharacter:        ;Procedure to print character on screen
                    ;Assume that ASCII value is in register AL
    MOV AH, 0x0E        ;Function 0E of int 10h [print character]
    MOV BH, 0x00        ;Page no.
    MOV BL, 0x07        ;Text attribute 0x07 is lightgrey font on black background
    INT 0x10            ;Call video interrupt
RET                  

PrintString:          ;Procedure to print string on screen
                    ;Assume that string starting pointer is in register SI

next_character:        ;Lable to fetch next character from string
  MOV AL, [SI]        ;Get a byte from string and store in AL
  INC SI                ;Increment SI pointer
  OR AL, AL            ;Check if value in AL is zero (end of string)
  JZ exit_function  ;If AL equals 0 then LET'S GET OUT OF HERE!
  CALL PrintCharacter;Otherwise print the character in AL
  JMP next_character;Fetch next character from string

exit_function:        ;End label
RET                    ;Return from procedure

setA20 db 'Setting the A20 line..', 0

TIMES 510 - ($ - $$) db 0;Fill the rest of sector with 0, otherwise it won't boot
DW 0xAA55                      ;Add boot signature at the end of bootloader


This post has been edited by Apples: 4 Oct, 2007 - 06:46 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 06:47PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month