Currently, I am trying to write a tiny OS from scratch. Unfortunately, In the first step, I faced a problem which drives me crazy. I write the following code as my bootloader.
.code16 #generate 16-bit code
.text #executable code location
.globl _start;
_start: #code entry point
. = _start + 510 #mov to 510th byte from 0 pos
.byte 0x55 #append boot signature
.byte 0xaa #append boot signature
In next step, I compile it with following commands:
as bootloader.s -o bootloader.o
ld –Ttext 0x7c00 --oformat=binary bootloader.o –o bootloader.bin
Then I create an img file with the following commands:
dd if=/dev/zero of=boot.img bs=512 count=2880
dd if=bootloader.bin of=boot.img
Finally, when I run bochs command in the terminal, Bochs just show me a dark window and nothing appeared. What is wrong?
Also, I tried the following code as bootloader but the result is same as previous.
.code16 #generate 16-bit code
.text #executable code location
.globl _start;
_start: #code entry point
#print letter 'H' onto the screen
movb $'H' , %al
movb $0x0e, %ah
int $0x10
#print letter 'e' onto the screen
movb $'e' , %al
movb $0x0e, %ah
int $0x10
#print letter 'l' onto the screen
movb $'l' , %al
movb $0x0e, %ah
int $0x10
#print letter 'l' onto the screen
movb $'l' , %al
movb $0x0e, %ah
int $0x10
#print letter 'o' onto the screen
movb $'o' , %al
movb $0x0e, %ah
int $0x10
#print letter ',' onto the screen
movb $',' , %al
movb $0x0e, %ah
int $0x10
#print space onto the screen
movb $' ' , %al
movb $0x0e, %ah
int $0x10
#print letter 'W' onto the screen
movb $'W' , %al
movb $0x0e, %ah
int $0x10
#print letter 'o' onto the screen
movb $'o' , %al
movb $0x0e, %ah
int $0x10
#print letter 'r' onto the screen
movb $'r' , %al
movb $0x0e, %ah
int $0x10
#print letter 'l' onto the screen
movb $'l' , %al
movb $0x0e, %ah
int $0x10
#print letter 'd' onto the screen
movb $'d' , %al
movb $0x0e, %ah
int $0x10
. = _start + 510 #mov to 510th byte from 0 pos
.byte 0x55 #append boot signature
.byte 0xaa #append boot signature