0

I started creating my first OS recently (I'm a complete beginner). I wanted to know how to connect the boot file with the kernel. I tried alone but I couldn't, how can I do?

This is the project:

boot.asm

ORG 0x7C00
BITS 16

start:

    mov si, msg_boot
    call Print
    
    jmp $

%include "lib/print.asm"

msg_boot: db "Test Boot" , 0

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

kernel.asm

BITS 16

start:

    mov si, msg_kernel
    call Print
    
    jmp $

%include "lib/print.asm"

msg_kernel: db "Test Kernel" , 0

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

nasm -f bin -o boot.bin boot.asm

nasm -f bin -o kernel.bin kernel.asm

type boot.bin, kernel.bin > os.bin

qemu-system-x86_64 os.bin

When I start qemu it said: "Boot failed"

enter image description here

7
  • 2
    Your kernel does not need a signature, but that is harmless. You must however load it yourself since the BIOS only loads the first sector. This is however unrelated to your problem since your boot sector isn't even loaded. Qemu isn't known to be picky and it works for me so double check you are using the code as shown. Commented May 25, 2023 at 18:34
  • @Jester I deleted the signature in the kernel and now it does not give me any problem with booting, prints on the screen the word "Test Boot", the only problem is that it does not run the kernel because it does not also print the word "Test Kernel". However, the codes are those shown Commented May 25, 2023 at 18:41
  • Recommended reading: wiki.osdev.org/Boot_Sequence Commented May 25, 2023 at 18:43
  • @teapot418 How should it be in practice? Commented May 25, 2023 at 18:49
  • 1
    How to load second stage boot loader from first stage? has a minimal runnable example, but see Michael Petch's comments for caveats. Boot loader doesn't jump to kernel code is a question with a pretty minimal attempt; Michael Petch's detailed answer explains why it's necessary for the MBR bootloader to do a bunch of things, and talks about the execution environment such code can expect. Commented May 26, 2023 at 2:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.