I am learning x86 real mode programming, and have written a small bootloader using QEMU to test it. I have chosen GNU assembler for learning.
Here is assembly code:
#
# boot.s
#
.section .text
.globl start
start:
//setup stack
mov $0x7c0, %ax
mov %ax, %ss
mov $512, %sp
//setup video
mov $0x0, %eax
mov $0x0, %al
int $0x10
//print a character say 'm'
mov $'m', %al
mov $0x0E, %ah
int $0x10
1:
jmp 1b
The following text is shown on the QEMU display:
Booting from Hard disk...
The problem: The message above is printed, and it remains like that appearing to do nothing.
The script I used to assemble, link is:
> to assemble : gcc -c boot.s
> to link : ld -T link.ld boot.o -o b.bin
> to put on bootsector of Hard-disk image
dd if=b.bin of=HD.img conv=notrunc
> to attach boot magic
echo -ne "\x55\xaa" | dd seek=510 bs=1 of=HD.img
> to emulate: qemu-system-i386 HD.img
The linker script copied from an online tutorial I saw somewhere, since I didn't know how to create one myself:
OUTPUT_FORMAT("binary")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
.text phys : AT(phys) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}
.data : AT(phys + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}
.bss : AT(phys + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .;
}
Do I need to specify any extra arguments or there is some mistake in code? I thought it's the setting up of stack but tried many possibilities but it didn't work.
How do I get past the hard disk booting message and have my bootloader display the letter m
on the screen?
My working platform is Fedora 23.