[SOLVED] int 13h/2 always fails

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
steveRoll
Posts: 2
Joined: Wed Nov 25, 2020 3:00 am

[SOLVED] int 13h/2 always fails

Post by steveRoll »

I have been following this book, and I got to the "Reading the Disk" part, where they used int 13h with ah=2 to read sectors from the disk. However, for me it always keeps failing - the carry flag is always set to 1, and the ah register is set to 0x1, which according to this page translates to "bad command passed to driver".
I have uploaded my code here.
I'm on Windows. I am compiling my assembly code with nasm, and I run the image with VirtualBox, where the image is loaded as a floppy disk. Everything was working fine until now.
Last edited by steveRoll on Wed Nov 25, 2020 8:39 am, edited 1 time in total.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: int 13h/2 always fails

Post by iansjack »

You are asking the interrupt to read 0 sectors from the disk, which is probably not what you intended.
steveRoll
Posts: 2
Joined: Wed Nov 25, 2020 3:00 am

Re: int 13h/2 always fails

Post by steveRoll »

iansjack wrote:You are asking the interrupt to read 0 sectors from the disk, which is probably not what you intended.
Oh wow, thanks!! I didn't even notice

For anyone else wondering, dh was a parameter to diskLoad, but also a parameter to int 13h/2 to specify which side of the disk to read, and I set it to 0 before actually copying dh to al, so its original value was lost.
Post Reply