OS development help - unable to load on real computer
Posted: Sun Oct 22, 2023 8:58 am
I have been using a couple of tutorials and using QEMU and VirtualBox to learn OS development. I have recently made three bootloaders which are a basic bootloader prints letter A using 0x10 interrupt, a bootloader that uses 0x13 to access disc and jumps to it, a bootloader that calls external C code.
I compile the code to .bin format using nasm and gcc -ffreestanding and then combine them using cat (in case of c kernel). The images work on qemu and if I turn them into floppy images they work on virtualbox too. When booting on a real computer the invalid partition table error is thrown so I followed the first part of this tutorial (https://wiki.osdev.org/Bootable_Disk#Cr ... _Partition) and used fdisk to just create partition table using option 'o' (DOS/MBR) then the last part adding the BIOS bootloader. This did not work. I have tested it on three computers, the first one says invalid partition table but does print letter B using the second bootloader if enter key is pressed, the second and third one does nothing except a blinking cursor. I have used legacy mode on all three computers. The third bootloader with external C code does not work or print anything on the real computer at all. Code for the first two bootloaders is below but I can post the bootloader with externel C code too if needed, it is just longer which is why I have not posted it.
Any guidance on what I am doing wrong? Thank you.
I compile the code to .bin format using nasm and gcc -ffreestanding and then combine them using cat (in case of c kernel). The images work on qemu and if I turn them into floppy images they work on virtualbox too. When booting on a real computer the invalid partition table error is thrown so I followed the first part of this tutorial (https://wiki.osdev.org/Bootable_Disk#Cr ... _Partition) and used fdisk to just create partition table using option 'o' (DOS/MBR) then the last part adding the BIOS bootloader. This did not work. I have tested it on three computers, the first one says invalid partition table but does print letter B using the second bootloader if enter key is pressed, the second and third one does nothing except a blinking cursor. I have used legacy mode on all three computers. The third bootloader with external C code does not work or print anything on the real computer at all. Code for the first two bootloaders is below but I can post the bootloader with externel C code too if needed, it is just longer which is why I have not posted it.
Code: Select all
; Basic bootloader to print letter A
[org 0x7c00]
mov ah, 0x0e ; tell bios we want to print character
mov al, 'A'
int 0x10
times 510 - ($ - $$) db 0
dw 0xAA55
Code: Select all
; Basic bootloader to print letter A
[org 0x7c00]
xor ax, ax
mov ds, ax
cld
mov ah, 0x02 ;Read
mov al, 0x02 ;Read second sector
mov ch, 0x00 ;Cylinder 0
mov cl, 0x02 ;Sector
mov dh, 0x00
xor bx, bx
mov es, bx
mov bx, 0x8001 ;where to jump after reading sector
int 0x13
jmp 0x8001 ;Now load the second sector
times 510 - ($ - $$) db 0
dw 0xAA55
mov ah, 0x0e
mov al, 'B'
int 0x10
jmp $ ;loop here