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

  • 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. – Jester May 25 '23 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 – Federico Occhiochiuso May 25 '23 at 18:41
  • Recommended reading: https://wiki.osdev.org/Boot_Sequence – teapot418 May 25 '23 at 18:43
  • @teapot418 How should it be in practice? – Federico Occhiochiuso May 25 '23 at 18:49
  • [How to make the kernel for my bootloader?](https://stackoverflow.com/q/33603842) is a working example – Peter Cordes May 25 '23 at 20:27
  • @PeterCordes Ok but I would like to start with something simple so that I fully understand all the code without copying code without even understanding it. Thanks anyway – Federico Occhiochiuso May 25 '23 at 20:56
  • 1
    [How to load second stage boot loader from first stage?](https://stackoverflow.com/a/32938408) has a minimal runnable example, but see Michael Petch's comments for caveats. [Boot loader doesn't jump to kernel code](https://stackoverflow.com/q/32701854) 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. – Peter Cordes May 26 '23 at 02:07

0 Answers0