Question

I have VBR with Protected Mode switch and Vesa initialization. But this problem I saw in another situations. When kernel have 3 sectors, it is no problem to load it into memory and jump to 0x7E00. But when kernel have 4 or more sectors, its code stop working... When I removed some features of long kernel for truncate length of the kernel into 3 sectors - code starts working.

    mov dl, 0x80            ; 80 - FF => HardDisk
    mov ah, 0x42
    mov si, .kernelStruct
    int 0x13

...

.kernelStruct:

    dw 16               ; byte of structure length + empty byte
    dw sectorsForLoad       ; sectors for load count
    dd Kernel               ; out address
    dq 1                    ; start sector

...

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

; kernel code from 0x7E00

times 512 - (($-$$) % 512) db 0
sectorsForLoad equ ($-$$-512) / 512

Why and what can I do? Thank you.

Was it helpful?

Solution

Two things:

  • Where is the stack (SS:SP) located? Maybe you overwrite the stack when reading from hard disk! If the stack is located at 0000:8500 for example this will be the case.
  • I saw BIOSes that required ES to have the same value as the address given in the control structure so ES must be equal to the word at [DS:SI+6]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top