Function 08h looks at the cell under the cursor of page BH and returns its character in AL and its attribute in AH. In a text mode that is a plain read of video memory. A graphics mode has no characters, only pixels, so the BIOS compares the dots at the cursor with its font and returns the character they match, or 0 if none does; AH means nothing there.
It serves for saving what a popup will cover, for reading what another program left on the screen, and for simple screen-reading tools. It reads one cell; for many, move the cursor each time or, much faster, read video memory at B800h directly. Here a Q printed by DOS is read back:
MOV DL, "Q"MOV AH, 02h ; DOS: print a QINT 21hMOV AH, 03h ; the cursor is now just after itMOV BH, 0INT 10h ; DH = row, DL = columnDEC DL ; one column back: onto the QMOV AH, 02hINT 10hMOV AH, 08h ; read the character and attribute thereINT 10h ; AL = character, AH = attributeMOV [CELL1], AXINC DL ; DX still holds the position: after the Q againMOV AH, 02hINT 10hMOV AH, 09hMOV DX, OFFSET MSG1INT 21hMOV DL, BYTE PTR [CELL1] ; the characterMOV AH, 02hINT 21hMOV AH, 09hMOV DX, OFFSET MSG2INT 21hMOV AL, BYTE PTR [CELL1+1] ; the attributeCALL PHEX2MOV AH, 09hMOV DX, OFFSET MSG3INT 21hCELL1 DW 0MSG1 DB ": read back $"MSG2 DB ", attribute $"MSG3 DB "h", 13, 10, "$"PHEX2: ; print AL as two hex digits; changes AX, CX, DXPUSH AXMOV CL, 4SHR AL, CL ; the high nibble firstCALL PDIG1POP AXAND AL, 0Fh ; then the low one, falling into PDIG1PDIG1:ADD AL, "0"CMP AL, "9"JBE PDIG2ADD AL, 7 ; "A".."F"PDIG2:MOV DL, ALMOV AH, 02h ; DOS: print DLINT 21hRET
Pitfalls
The cursor does not move, so a loop over a line must step it with function 02h. In graphics modes the matching works only for characters drawn with the same font, in one colour, on a background of colour 0; text drawn over a picture, in another font or with XOR reads as 0. In text modes the result is exact.