Clear Screen Buffer in MS-DOS 6.22
Clearing the screen buffer in MS-DOS 6.22 is a fundamental task used to wipe the active display, purge visible text artifacts, and reset the cursor to the top-left position. This article explains the standard built-in command used to clear the video display memory, how it interacts with the hardware buffer, and alternative methods using ANSI escape sequences.
The Standard Command: CLS
The primary command sequence to clear the screen buffer in MS-DOS 6.22 is:
CLS
Typing CLS (Clear Screen) at the command prompt and
pressing Enter clears the entire visible console
window. Internally, MS-DOS executes this via BIOS Interrupt
10h (specifically function 06h or
07h to scroll the active display page) or directly
overwrites the text-mode video memory buffer at memory segment
0xB800 (for standard color text modes) or
0xB000 (for monochrome modes).
When executed, CLS performs the following actions:
- Replaces all character cells across the 80x25 text grid with blank
space characters (
ASCII 32or0x20). - Applies the default color attribute (typically light gray on black,
attribute
0x07). - Resets the cursor coordinates to row 0, column 0 (the top-left corner).
Clearing the Buffer with ANSI.SYS
If your CONFIG.SYS file loads the ANSI driver
(DEVICE=C:\DOS\ANSI.SYS), you can also clear the screen
buffer using standard ANSI escape sequences.
The escape code sequence to clear the screen buffer is:
ESC[2J
You can test this directly from the MS-DOS prompt by using the
PROMPT command to generate the escape character:
PROMPT $e[2J$p$g
Once entered, the screen buffer immediately flushes, the screen
clears, and the cursor returns to the home position. To restore the
default prompt behavior afterward, type PROMPT $p$g.
Using CLS in Batch Files
In automated batch scripts (.BAT), simply place
CLS on its own line wherever a clean screen buffer is
required:
@ECHO OFF
CLS
ECHO MS-DOS 6.22 Setup Utility
ECHO =========================
This ensures any prior output from previously executed commands is completely cleared from the active screen buffer before your script displays new information.