Why is INT 0x13 AH=0x02 crashing?

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.
Octocontrabass
Member
Member
Posts: 5604
Joined: Mon Mar 25, 2013 7:01 pm

Re: Why is INT 0x13 AH=0x02 crashing?

Post by Octocontrabass »

Isaac wrote:Anything wrong with my DAP?
That depends. Where's the code to fill in the rest of it?
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why is INT 0x13 AH=0x02 crashing?

Post by iansjack »

Isaac wrote:Anything wrong with my DAP?
Yes. Bytes 9-15 of it are undefined.
Isaac
Member
Member
Posts: 66
Joined: Sat Dec 07, 2013 7:08 pm

Re: Why is INT 0x13 AH=0x02 crashing?

Post by Isaac »

I followed what they say on Wikipedia. Look: http://en.wikipedia.org/wiki/INT_13H#IN ... From_Drive
The table shows that the last field in the DAP goes from 0x8-0xF. I filled in that field. Even though I didn't use up ALL the space, isn't it okay?
Octocontrabass
Member
Member
Posts: 5604
Joined: Mon Mar 25, 2013 7:01 pm

Re: Why is INT 0x13 AH=0x02 crashing?

Post by Octocontrabass »

Isaac wrote:Even though I didn't use up ALL the space, isn't it okay?
You're missing some fundamental concepts of assembly programming.

If I do this:

Code: Select all

mov al, 5
mov [bx], al
mov ax, [bx]
What value will be stored to AX?
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why is INT 0x13 AH=0x02 crashing?

Post by iansjack »

Suppose that before you fill those 8 bytes they contain:

0xd 0x4 0x0 0x5 0x8 0x3 0x0 0x1

Now you write 0x2 to the first byte. What number does that 8-bit field (that says what sector you want to start reading at) now contain? And what are the chances that there is a sector of that number on your disk?

You have an uninitialized variable; that's one of the commonest bugs in programming. You need to write all 8 bytes of the number not just the least significant one. With a little simple debugging you would catch errors like this immediately.
Isaac
Member
Member
Posts: 66
Joined: Sat Dec 07, 2013 7:08 pm

Re: Why is INT 0x13 AH=0x02 crashing?

Post by Isaac »

I fixed up my DAP:

Code: Select all

mov byte [bx],0x10
mov byte [bx+1],0x0
mov word [bx+2],4
mov dword [bx+4],0x9000
mov dword [bx+8],2
mov dword [bx+12],0
But it still prints an error message. Why is that?
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why is INT 0x13 AH=0x02 crashing?

Post by iansjack »

I don't know. What error code is the BIOS call returning?
Isaac
Member
Member
Posts: 66
Joined: Sat Dec 07, 2013 7:08 pm

Re: Why is INT 0x13 AH=0x02 crashing?

Post by Isaac »

I don't really know much about error codes. But the number returned in AH is 0x1.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why is INT 0x13 AH=0x02 crashing?

Post by iansjack »

Octocontrabass
Member
Member
Posts: 5604
Joined: Mon Mar 25, 2013 7:01 pm

Re: Why is INT 0x13 AH=0x02 crashing?

Post by Octocontrabass »

Ralf Brown's Interrupt List wrote:01h: invalid function in AH or invalid parameter
It sounds like there's still something wrong with the values being passed to int 0x13.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why is INT 0x13 AH=0x02 crashing?

Post by iansjack »

Or, possibly, the BIOS doesn't support the call. Less likely but it should be checked first.
Isaac
Member
Member
Posts: 66
Joined: Sat Dec 07, 2013 7:08 pm

Re: Why is INT 0x13 AH=0x02 crashing?

Post by Isaac »

The BIOS supports the call. I just can't figure out what's wrong with my DAP.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Why is INT 0x13 AH=0x02 crashing?

Post by thepowersgang »

Could you please post the code that invokes the system call (not just the code that populates the DAP). Preferably in the form that you're compiling (not just cut+pasted from separate sections of code).
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Octocontrabass
Member
Member
Posts: 5604
Joined: Mon Mar 25, 2013 7:01 pm

Re: Why is INT 0x13 AH=0x02 crashing?

Post by Octocontrabass »

Isaac wrote:I just can't figure out what's wrong with my DAP.
The DAP is not the only thing you need to check. Get in a debugger and make sure all of the values you're passing to int 0x13 are correct.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why is INT 0x13 AH=0x02 crashing?

Post by iansjack »

Isaac wrote:The BIOS supports the call. I just can't figure out what's wrong with my DAP.
How do you know? You haven't shown any code that tests this.

The DAP business is easy - use a debugger to inspect it just before you make the BIOS call. Is it what you expect it to be? And are your expectations correct?
Post Reply