How to start to build OS/Kernel

54 Views Asked by At

I'm starting to program my first "operating system", for now I have created only the bootloader but I would like to add the kernel as well as I can. Do I need to create a linker.ld file? (I've never used a linker file)

Do I have to write the kernel in C, in assembly or do I necessarily have to use both? Please can you give me some small examples just to make me understand how to start, I'm a beginner and I don't know how to start.

In the OS directory there are only Makefile, build folder and scr folder.

This is the file scr/boot.asm:

ORG 0
BITS 16

boot:
    init:
        jmp 0x7c0:start

    start:
        cli            ; clear interrupts
        mov ax, 0x7c0
        mov ds, ax     ; data segment
        mov es, ax     ; extra segment
        mov ax, 0x00
        mov ss, ax     ; stack segment
        mov sp, 0x7c00 ; stack pointer
        sti            ; enable interrupts

        jmp $

times 510 - ($ - $$) db 0
dw 0xAA55

Makefile:

SCR_DIR = scr
BUILD_DIR = build

main:
    nasm -f bin -o $(BUILD_DIR)/boot.bin $(SCR_DIR)/boot.asm

    qemu-system-x86_64 $(BUILD_DIR)/boot.bin
0

There are 0 best solutions below