I have been trying to roll my own bootloader for the past couple of days and I'm having some problems with VirtualBox.
Everything seems to be working fine until I attempt to set the stack pointer, at which point my "kernel" freezes.
I discovered this by attempting to print characters on the screen. If I don't touch the stack pointer, they print. If I do, they don't (hence the freeze).
This is the line of code that is problematic:
Code: Select all
movw $0x9c00, %sp
Code: Select all
.section .data
ch: .byte 0x50
.section .text
.globl bootloader
bootloader:
cli
movw $0, %ax
movw %ax, %es
movw $0x07c0, %ax
movw %ax, %ds
movw %ax, %ss
movw $0x9c00, %sp
sti
movb $0x0E, %ah
movb ch, %al
int $0x10
movb $0x41, %al
int $0x10
movb $0x43, %al
int $0x10
movb $0x41, %al
int $0x10
halt:
jmp halt