INT 13h AH=02h copies whole sectors from the disk into memory at ES:BX: AL sectors, 512 bytes each, starting at the address given by CH, CL and DH on drive DL (see INT 13h for how the cylinder is packed into CH and CL). The buffer must be big enough for all of them. On success CF = 0 and AL says how many were read.
The first sector of a hard disk, cylinder 0, head 0, sector 1, is the master boot record: boot code, then from offset 1BEh four 16-byte partition entries, and at 1FEh the signature bytes 55h AAh that mark the sector as bootable. The example reads it and prints those last two bytes:
PUSH CSPOP ESMOV BX, OFFSET SECT1 ; ES:BX = a 512-byte bufferMOV AX, 0201h ; AH = 02h read, AL = 1 sectorMOV CX, 0001h ; CH = cylinder 0, CL = sector 1 (sectors count from 1)MOV DX, 0080h ; DH = head 0, DL = 80h, the first hard diskINT 13hJC FAIL1 ; CF = 1: AH = what went wrongMOV DX, OFFSET OK1MOV AH, 09h ; DOS: print the $-string at DS:DXINT 21hMOV AL, SECT1+1FEh ; the boot signature: 55h AAh on a real diskCALL PHEX2MOV DL, " "MOV AH, 02h ; DOS: print the character in DLINT 21hMOV AL, SECT1+1FFhCALL PHEX2JMP DONE1FAIL1:MOV BL, AH ; keep the statusMOV DX, OFFSET BAD1MOV AH, 09h ; DOS: print the $-string at DS:DXINT 21hMOV AL, BLCALL PHEX2DONE1:OK1 DB "read ok, bytes at 1FEh: $"BAD1 DB "read failed, AH = $"SECT1 DB 512 DUP (0)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
Limits
The buffer must not cross a 64 KB physical boundary (an address that is a multiple of 10000h): the PC's DMA controller, used for floppies, cannot carry over into the next 64 KB page, and the BIOS reports error 09h. Sector-sized buffers in a small program are usually safe, but a big one should be checked. Reads of several sectors should stay within one track on old BIOSes; reading one sector at a time is the safe choice. And floppy reads fail now and then for harmless reasons: retry three times with INT 13h AH=00h in between.
In DOSBox-X
Only drives attached as images (IMGMOUNT, or a booted disk) have sectors. For a mounted folder DOSBox-X answers most reads with CF = 1 and AH = 01h; the one exception is a read of cylinder 0, head 0, sector 1 of a hard-disk number, which some old installers use to check that a disk exists. That read "succeeds" and writes only a partition-entry marker (80h at 1BEh, 06h at 1C2h) into the buffer, leaving the rest as it was, which is why the example clears its buffer first and then sees 00 00 where the signature would be.