Simple bootloader doesn't work on any physical machine.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
theFeadow
Posts: 1
Joined: Sun Apr 23, 2023 3:02 am

Simple bootloader doesn't work on any physical machine.

Post by theFeadow »

I've tried it using QEMU as well as VirtualBox, it works without any issues.

Now, I've tried a multitude of ways for writing the bootloader to a USB memory stick and booting up a physical machine to display "FeadowOS", nothing works. I've been trying for 8 hours or so.. I've tried different combinations of search keywords, I've asked chatGPT, I've looked in this website, both in the main section and the forums. I've tried on 2 different laptops. I made sure to enable "Legacy Booting" whenever possible. Nothing works. Please advise. I'm an absolute beginner.

Here's the code for the bootloader before assembly:

Code: Select all

mov ah, 0x0e
mov al, 'F'
int 0x10
mov ah, 0x0e
mov al, 'e'
int 0x10
mov ah, 0x0e
mov al, 'a'
int 0x10
mov ah, 0x0e
mov al, 'd'
int 0x10
mov ah, 0x0e
mov al, 'o'
int 0x10
mov ah, 0x0e
mov al, 'w'
int 0x10
mov ah, 0x0e
mov al, 'O'
int 0x10
mov ah, 0x0e
mov al, 'S'
int 0x10

jmp $

times 510-($-$$) db 0
db 0x55, 0xaa
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: Simple bootloader doesn't work on any physical machine.

Post by nullplan »

Depending on the system, it may try to emulate a floppy when booting from USB stick. And floppies have a BIOS Parameter Block at the start. Don't recall how long it is, so why don't you add a skip to byte 128 to your bootsector?

Code: Select all

jmp start
times 128-($-$$) db 90h
start:
[rest of the code here]
If that works then part of the start of your bootsector gets overwritten. Or else the BIOS also verifies that the boot sector starts with a jmp opcode.

Otherwise I don't really know. I mean, yes, you are not setting up a stack, but the BIOS must have set up a stack that does not interfere with the boot sector area at least when you are doing these simple calls, since BIOS loaded a sector to the right place. You can add that part, it doesn't hurt:

Code: Select all

xor ax, ax
mov ss, ax
mov sp, 7c00h
That sets up the stack to start below the boot sector itself, so now it definitely won't interfere with the code.
Carpe diem!
Post Reply