To write your own boot loader, you will require the following:
1. Storage media where your boot loader will reside. (I have used Virtual Box hard-disk for this purpose)
2. A text editor.
3. Assembler.
4. Optionally Hex editor, in case Virtual Box is used as storage media
Step 1: Virtual HD creation
a. Create a virtual hard disk (VDI) in Virtual Box.
b. Look for the location of the disk.
For example, the location of a newly created disk shown above is at C:\Users\vilangov\VirtualBox VMs\hang bootloader\hang bootloader.vdi
Step 2: Write a hanging bootloader assembly code
a. Open a text editor, for example Notepad and copy the following assembly code.
Save it as hang.asm
;hangs when boots
[BITS 16]
[ORG 0x7C00]
JMP $
TIMES 510-($-$$) db 0
DW 0xAA55
Step 3: Assemble the code:
Use the NASM assmbler to assemble the code.
nasm -f bin hang.asm -o hang.bin
This will create a 512 byte program.
You just created your bootloader 'hang.bin' that will just hang!
Step 4: Make Virtual Box bootstrap your bootloader
a. Open the virtual harddisk created in Step 1 using a Hex editor
b. Somewhere in location 0x158, you will find the location of the bootloader which will be placed in location 0x7c00 of physical memory
For example, the Virtual Box disk at location 0x158 shows 00 30. This is a little endian machine. So the actual start of the disk or IOW the bootloader is located at 0x3000.
c.Copy paste the entire 512 byte program generated from step 3 to location 0x3000 of the virtual hard disk.
d. Now boot the Virtual box, you will now see nothing because the bootloader just hangs!!
References:
Writing a Simple Operating System from Scratch
Using Virtual Box as a bootloader testing environment
1. Storage media where your boot loader will reside. (I have used Virtual Box hard-disk for this purpose)
2. A text editor.
3. Assembler.
4. Optionally Hex editor, in case Virtual Box is used as storage media
Step 1: Virtual HD creation
a. Create a virtual hard disk (VDI) in Virtual Box.
b. Look for the location of the disk.
For example, the location of a newly created disk shown above is at C:\Users\vilangov\VirtualBox VMs\hang bootloader\hang bootloader.vdi
Step 2: Write a hanging bootloader assembly code
a. Open a text editor, for example Notepad and copy the following assembly code.
Save it as hang.asm
;hangs when boots
[BITS 16]
[ORG 0x7C00]
JMP $
TIMES 510-($-$$) db 0
DW 0xAA55
Step 3: Assemble the code:
Use the NASM assmbler to assemble the code.
nasm -f bin hang.asm -o hang.bin
This will create a 512 byte program.
You just created your bootloader 'hang.bin' that will just hang!
Step 4: Make Virtual Box bootstrap your bootloader
a. Open the virtual harddisk created in Step 1 using a Hex editor
b. Somewhere in location 0x158, you will find the location of the bootloader which will be placed in location 0x7c00 of physical memory
For example, the Virtual Box disk at location 0x158 shows 00 30. This is a little endian machine. So the actual start of the disk or IOW the bootloader is located at 0x3000.
c.Copy paste the entire 512 byte program generated from step 3 to location 0x3000 of the virtual hard disk.
d. Now boot the Virtual box, you will now see nothing because the bootloader just hangs!!
References:
Writing a Simple Operating System from Scratch
Using Virtual Box as a bootloader testing environment