Code: Select all
bits 16
global _start
extern kmain
section .text
_start:
cli
mov ax, 07C0h ; Set up 4K stack space after this bootloader
add ax, 288 ; (4096 + 512) / 16 bytes per paragraph
mov ss, ax
mov sp, 4096
mov ax, 07C0h ; Set data segment to where we're loaded
mov ds, ax
sti
call kmain
Code: Select all
void kmain(void) {
const char* string = "stage1 loaded\0";
volatile char *video = (volatile char*)0xB8000;
while( *string != 0 )
{
*video++ = *string++;
*video++ = 0x07;
}
}
Code: Select all
ENTRY(_start)
STARTUP(boot.o)
INPUT(kernel.o)
SECTIONS
{
.text :
{
*(.text);
}
}
OUTPUT_FORMAT(binary)
OUTPUT(myos.bin)
Code: Select all
nasm -f elf -o boot.o boot.asm
i686-elf-gcc -c kernel.c -o kernel.o -std=gnu99 -ffreestanding -O2 -Wall -Wextra
i686-elf-gcc -T kernel.ld -o myos.bin -ffreestanding -O2 -nostdlib -lgcc
Code: Select all
dd if=/dev/zero of=floppy.img bs=512 count=2880
dd if=myos.bin of=floppy.img
Thanks for your help.