Functions 06h and 07h move the contents of a window, a rectangle of the screen given by its top-left corner in CX and its bottom-right corner in DX, by AL lines. 06h moves them up: the top AL lines disappear and AL blank lines appear at the bottom. 07h moves them down, and the blank lines appear at the top. The blanks are spaces in attribute BH. With AL = 0, or AL at least the height of the window, every line becomes blank: the window is cleared.
This is how the BIOS itself scrolls the screen when teletype output passes the bottom line, and how programs scroll part of the screen, a message area or a list, while the rest stays put. Both work on the active page. In graphics modes they work as well, filling with BH as a colour, but slowly on old cards.
Clearing the screen
MOV AX, 0600h ; scroll up, AL = 0: clearMOV BH, 07h ; light grey on blackMOV CX, 0000h ; from row 0, column 0MOV DX, 184Fh ; to row 24 (18h), column 79 (4Fh)INT 10hMOV AH, 02h ; and the cursor homeMOV BH, 0MOV DX, 0000hINT 10h
That is all a CLS needs. Setting the mode again also clears, but is slower and resets everything else; with another BH the same call paints the whole screen, BH = 1Fh for white on blue. The example paints a window near the top right, then scrolls it both ways, so each new line shows the attribute of the call that made it:
MOV AX, 0600h ; AL = 0: clear the windowMOV BH, 1Fh ; white on blueMOV CX, 0132h ; top left: row 1, column 50MOV DX, 054Dh ; bottom right: row 5, column 77INT 10hMOV AX, 0602h ; scroll up 2 linesMOV BH, 2Fh ; the two new bottom lines: greenMOV CX, 0132hMOV DX, 054DhINT 10hMOV AX, 0701h ; AH = 07h: scroll down 1 lineMOV BH, 4Fh ; the new top line: redMOV CX, 0132hMOV DX, 054DhINT 10hMOV AH, 09hMOV DX, OFFSET MSG1INT 21hMSG1 DB "Window painted and scrolled", 13, 10, "$"
Pitfalls
The corners are not checked: a corner off the screen, or a top-left below or right of the bottom-right, gives odd results that differ between BIOSes. The scroll code of some early BIOSes destroys BP, so keep nothing there across the call. On a real CGA the BIOS blanks the display while it moves the text in 80-column modes, to avoid "snow", so scrolling flickers. Only the active page scrolls; for other pages, or for speed, move the memory yourself with REP MOVSW.