INT 13h AH=00h resets the disk controller and recalibrates the drive: the heads go back to cylinder 0 so that the controller knows where they are again. Nothing on the disk changes. After a failed read, write or seek it brings the hardware back into a known state, and the next attempt often works. For a hard disk number (80h and up) most BIOSes reset the floppy controller as well.
The classic retry loop:
MOV SI, 3 ; three triesTRY1:MOV AX, 0201h ; read one sectorINT 13h ; (CX, DX, ES:BX set up before)JNC OK1 ; successMOV AH, 00h ; failed: reset the drive...INT 13h ; (DL still holds the drive)DEC SIJNZ TRY1 ; ...and try again; three failures: report the errorOK1:
The example resets the first hard disk and then reads the status of the last operation with AH=01h:
MOV AH, 00h ; BIOS disk: resetMOV DL, 80h ; the first hard diskINT 13hMOV DX, OFFSET OK1JNC SHOW1 ; CF = 0: doneMOV DX, OFFSET BAD1SHOW1:MOV AH, 09hINT 21hMOV AH, 01h ; BIOS disk: status of the last operationMOV DL, 80hINT 13h ; AH = status, 00h = no errorMOV AL, AHCALL PHEX2OK1 DB "reset 80h: ok, last status $"BAD1 DB "reset 80h: failed, last status $"PHEX2 PROC NEAR ; print AL as two hex digits; keeps every registerPUSH AXPUSH CXPUSH DXMOV DH, AL ; keep the byteMOV CL, 4SHR AL, CL ; the high nibbleCALL HEXN1MOV AL, DHAND AL, 0Fh ; the low nibbleCALL HEXN1POP DXPOP CXPOP AXRETHEXN1:ADD AL, "0"CMP AL, "9"JBE HEXN2ADD AL, 7 ; past "9": "A".."F"HEXN2:MOV DL, ALMOV AH, 02hINT 21hRETPHEX2 ENDP
Pitfalls
Do not reset after every successful operation: a recalibration moves the heads to track 0 and costs time. On a floppy, error 06h (disk changed) is not a failure but a warning that the disk in the drive is a new one; retry, and drop anything cached from the old disk. In DOSBox-X the reset always succeeds when no disk images are attached, since there is no controller state to lose.