Bogus int 13h error 0xc in qemu?

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
clementttttttttt
Member
Member
Posts: 70
Joined: Tue Jul 14, 2020 4:01 am
Libera.chat IRC: clementttttttttt

Bogus int 13h error 0xc in qemu?

Post by clementttttttttt »

For some reasons, int 13h is still setting the carry flag and complaining about "media type not found" in qemu, even though I can prove that the sectors are correctly loaded.
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bogus int 13h error 0xc in qemu?

Post by Octocontrabass »

It's hard to say what's wrong without seeing your code.
clementttttttttt
Member
Member
Posts: 70
Joined: Tue Jul 14, 2020 4:01 am
Libera.chat IRC: clementttttttttt

Re: Bogus int 13h error 0xc in qemu?

Post by clementttttttttt »

code is attached as file.
Attachments
horizonboot.asm
(1.92 KiB) Downloaded 37 times
wxwisiasdf
Member
Member
Posts: 34
Joined: Sat Sep 07, 2019 5:17 pm
Libera.chat IRC: Superleaf1995

Re: Bogus int 13h error 0xc in qemu?

Post by wxwisiasdf »

clementttttttttt wrote:code is attached as file.
You're not clearing flags before calling INT 0x13. This is a big nono. INT 0x13 calls are known to assume that the carry flag is clear when it is not. They also love to destroy BP.
:-)
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Bogus int 13h error 0xc in qemu?

Post by Octocontrabass »

Code: Select all

.nsectors dw 16
You're reading 16 sectors. Does your disk have 16 sectors for you to read?

Code: Select all

    mov sp,0x4000
    xor ax,ax
    mov ss,ax
An interrupt can happen between setting SP and setting SS. Rearrange these instructions so that the MOV to SP immediately follows the MOV to SS, or disable interrupts with CLI.

Code: Select all

    lgdt [gdtinfo]
    pop ds
    mov ah,0x41
    mov bx,0x55aa
    mov dl,0x80
    int 13h
Support for the EDD functions will vary depending on the drive number in DL. You must specify the same number in DL that you use for later calls.

You make BIOS calls between loading the GDTR and switching to protected mode. BIOS calls may modify the GDTR.

Code: Select all

    int 13h
    cli
    cmp ah,0xc
    je skip
    jc error
The CMP instruction modifies the carry flag.

Code: Select all

	lodsb
You need to clear the direction flag.

Code: Select all

    mov ax,0x4f02
    mov bx,0x4113
    int 10h
This won't work on some hardware.

Code: Select all

    and al,0xfe
    mov cr0,eax
    jmp $
You need a far JMP after a MOV to CR0 that modifies CR0.PE.
Post Reply