INT 13h AH=03h is the mirror of INT 13h AH=02h: the same registers, but the data goes from ES:BX to the disk. It writes raw sectors with no idea what they contain. DOS is not asked and not told: its file allocation table, directories and buffers stay as they were, even if the sector just overwritten held part of them.
That makes it the tool of disk copiers, formatters, boot-sector installers and disk editors, and the classic way to destroy a disk by accident. Overwriting sector 1 of a hard disk replaces the partition table, after which no partition can be found; writing over a FAT or a directory loses files.
The example below is not runnable on purpose: these examples run on a real DOSBox-X, and writing sectors is exactly what they must never do. On the workbench's mounted folder it would only fail (CF = 1, AH = FFh, since there is no disk behind drive C), but with a disk image mounted it would really write. The snippet reads the boot sector of the floppy in A:, changes nothing, and writes it back to the same place, which is the safe shape of a sector edit:
PUSH CSPOP ESMOV BX, OFFSET SECT1 ; ES:BX = 512 bytesMOV AX, 0201h ; read cylinder 0, head 0, sector 1...MOV CX, 0001hMOV DX, 0000h ; ...of drive 00h, the floppy in A:INT 13hJC FAIL1; ... here a disk editor would change bytes in SECT1 ...MOV AX, 0301h ; write the sector back, same addressMOV CX, 0001hMOV DX, 0000hINT 13h ; CF = 1, AH = 03h if write protectedJC FAIL1
Pitfalls
Status 03h means the disk is write protected, the only error a user can fix. After writing behind DOS's back, DOS may still hold the old contents in its buffers and later write them over yours; disk tools flush with INT 21h AH=0Dh before and after. The same 64 KB DMA boundary rule as for reading applies. Many antivirus programs and some BIOSes watch this function and warn when the boot sector or partition table is written, because that is what boot-sector viruses did.