Page 1 of 1

[SOLVED] int 13h/2 always fails

Posted: Wed Nov 25, 2020 3:22 am
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.

Re: int 13h/2 always fails

Posted: Wed Nov 25, 2020 5:22 am
by iansjack
You are asking the interrupt to read 0 sectors from the disk, which is probably not what you intended.

Re: int 13h/2 always fails

Posted: Wed Nov 25, 2020 8:38 am
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.