I tried to create a bootloader using this , but when it starts, it shows:
disk read error!
If I ignore this, in a later part it will show me an incorrect memory mapping. I also followed some other sources, but in vain. Looks like I'm just copying what they do. Even if I am a little different, every new type is generated every time.
Should I use an already built bootloader or what should I do?
The disk boot error code is as follows:
[org 0x7c00] KERNEL_OFFSET equ 0x1000 mov [BOOT_DRIVE], dl mov bp, 0x9000 mov sp, bp mov bx, MSG_REAL_MODE call print_string call load_kernel jmp $ print_string: pusha mov ah, 0x0e loop: mov al,[bx] cmp al, 0 je return int 0x10 inc bx jmp loop return: popa ret disk_load: push dx mov ah, 0x02 mov al, dh mov ch, 0x00 mov dh, 0x00 mov cl, 0x02 int 0x13 jc disk_error pop dx cmp dh, al jne disk_error ret disk_error : mov bx, DISK_ERROR_MSG call print_string jmp $ DISK_ERROR_MSG db "Disk read error!", 0 [bits 16] load_kernel: mov bx, KERNEL_OFFSET mov dh, 15 mov dl, [BOOT_DRIVE] call disk_load ret ; Global variables BOOT_DRIVE db 0 MSG_REAL_MODE db "Started in 16-bit Real Mode", 0 ; Bootsector padding times 510-($-$$) db 0 dw 0xaa55
I use this command to build and run my bootloader:
nasm boot.asm -f bin -o boot.bin && qemu-system-i386 boot.bin
I am stuck at this point. My bootloader displays disk read error . If I ignore it at this point in time, then it creates problems while running my .c kernel. It seems to be using the wrong memory mapping.
assembly qemu osdev kernel bootloader
Palvit garg
source share