Page 1 of 1
Bogus int 13h error 0xc in qemu?
Posted: Tue Feb 09, 2021 9:32 pm
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.
Re: Bogus int 13h error 0xc in qemu?
Posted: Tue Feb 09, 2021 9:43 pm
by Octocontrabass
It's hard to say what's wrong without seeing your code.
Re: Bogus int 13h error 0xc in qemu?
Posted: Tue Feb 09, 2021 10:21 pm
by clementttttttttt
code is attached as file.
Re: Bogus int 13h error 0xc in qemu?
Posted: Tue Feb 09, 2021 10:33 pm
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.
Re: Bogus int 13h error 0xc in qemu?
Posted: Tue Feb 09, 2021 10:53 pm
by Octocontrabass
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.
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.
You need a far JMP after a MOV to CR0 that modifies CR0.PE.