os-tutorial icon indicating copy to clipboard operation
os-tutorial copied to clipboard

Problem with example 14 on real machine

Open AhmedAlaa2024 opened this issue 3 years ago • 1 comments

I tried running the example 14 on a real machine it's a Pentium dual-core. I debugged the code and I found that the problem starts at the line call KERNEL_OFFSET I think the kernel is not loaded here, however, the disk procedures don't return any error, so I assume the int 0x13 already loads the kernel but where is it?

I don't know if my inspections are right or not. Any help, please?

AhmedAlaa2024 avatar Jun 14 '22 21:06 AhmedAlaa2024

Even i had problems running things on real machine. Eventually i found a solution, that was just to set the CS register to zero. CS being non-zero causes problem with offsetting of the memory thats why.

here is how it worked for me:

; --[init stuf for your bootloader]--

jmp 0:mainBOOT         ; setting CS register to zero with the jump

mainBOOT:
    mov [DISK], dl     ; saving the drive number we booted from
    mov bp, 0x9000     ; setting the base pointer far from kernel load location, cuz stack grows downwards
    mov sp, bp         ; setting stack pointer

; --[the rest of your bootloader]--

tell me if it works or not.
PS: last time i made a fake entry for the drive as a 1.44 MB floppy disk. wasted 5 HOURS! then came to know that CS register was non-zero. dont make the same mistake xd.

OpGamer3000 avatar Oct 16 '22 10:10 OpGamer3000