Search code examples
assemblyboot16-bit

INT 13h, get status of last op


I'm writing a bootloader for BIOS in 16-bit real mode, using qemu as my emulator.

I have some code that fails to read from my HD. That's OK, but what actually bothers me is when I try to get the status code from that operation using the "Get Status of Last Drive Operation".

According to this wikipedia resource, I can simply set AH to 1, and set DL to my desired drive (which I've verified is 0x80). Then, when I invoke int 13h, AL should have the status code in it.

However, when I do this, the carry flag gets set, indicating that my attempt to read the status itself failed.

Other that specifying the wrong drive, I don't see how it could possibly fail.

So my question is, what are the ways this command (INT 13h, AH 01h) could possibly fail?

Here's my code:

get_status:
    mov ah, 0x01    ; status fxn
    mov dl, 0x80    ; 0x80 is our drive
    int 0x13        ; call fxn

    jc print_status_failure
    jmp $

print_status_failure:
    mov ax, FAIL_MSG
    call print_string
    jmp $

Solution

  • Then, when I invoke int 13h, AL should have the status code in it.

    BIOS function 01h for INT 13h only returns a result in the AH register. The carry flag is not defined and so you should never test for any failure after having invoked this function!