The text cursor is drawn by the card itself, as a blinking band of scan lines inside the character cell. Function 01h chooses the band: CH is its first line and CL its last, counted from 0 at the top of the cell. On a CGA a cell is 8 lines high and the usual underline is lines 6 to 7; monochrome and EGA cells are 14 lines high, VGA cells 16.
So that programs need not care, EGA and VGA BIOSes translate CGA-style values in the 25-line colour text modes, which IBM called cursor emulation: 0607h becomes the underline and 0007h a full block, whatever the real cell height. CGA values therefore work everywhere. Setting bit 5 of CH hides the cursor, which full-screen programs do while they draw.
| CX | Cursor (CGA values) |
|---|---|
| 0607h | the usual underline |
| 0007h | a full block |
| 0407h | the lower half (insert mode in many editors) |
| 2000h | hidden |
The BIOS keeps the shape at 40h:60h in its data area, and function 03h returns it in CX. A program that changes it should read it first and put it back before it exits; DOS does not, and a missing or odd cursor at the prompt is confusing.
MOV AH, 03h ; read the cursor: CX = its shapeMOV BH, 0INT 10hMOV [SHAPE1], CX ; keep itMOV AH, 01h ; set the shapeMOV CX, 0007h ; scan lines 0 to 7: a full blockINT 10hMOV AH, 09hMOV DX, OFFSET MSG1 ; the block blinks at the end of this textINT 21hMOV CX, 001Eh ; wait 2 s: CX:DX = 1E8480h microsecondsMOV DX, 8480hMOV AH, 86h ; BIOS: waitINT 15hMOV AH, 01h ; the old shape backMOV CX, [SHAPE1]INT 10hMOV AH, 09hMOV DX, OFFSET MSG2INT 21hMOV AX, [SHAPE1]CALL PHEX4 ; the shape we foundMOV AH, 09hMOV DX, OFFSET MSG3INT 21hSHAPE1 DW 0MSG1 DB "Block cursor for 2 seconds: $"MSG2 DB "back, it was $"MSG3 DB "h", 13, 10, "$"PHEX4: ; print AX as four hex digitsPUSH AXMOV AL, AHCALL PHEX2 ; the high byte firstPOP AXPHEX2: ; 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
There is a cursor only in text modes; in graphics modes the BIOS draws none and this function has no visible effect. On the original CGA, values above 7 or a first line below the last give a split or missing cursor; the VGA's emulation maps odd values in its own way, so keep to 0–7 in CGA terms. Emulation can be switched off with INT 10h AH=12h (BL = 34h), and then the values are real scan lines of the 16-line cell. A mode set restores the standard underline.