A program opens a screen device by using Open File with Handle (Interrupt 21h Function 3Dh). The function takes the device name CON and returns a handle for the screen device. The program uses the handle with Write File or Device (Interrupt 21h Function 40h) to write to the screen.
In ASCII mode, MS-DOS sends all characters to the screen, checks at the keyboard for control characters as it writes and, if it finds one, carries out its corresponding action. Tab characters (ASCII 09h) are expanded to space characters based on eight-space tab settings. MS-DOS continues to write characters to the screen until it has sent the requested number of characters or reached an end-of-file character (ASCII 1Ah).
In binary mode, MS-DOS writes the exact number of characters requested by the program. It does not process control characters, expand tab characters, or stop writing at the end-of-file character.
By default, the cursor moves to the right for each new character. It moves down for a linefeed character (ASCII 0Ah) and to the leftmost column for a carriage-return character (ASCII 0Dh). For programs that need more complicated screen control, MS-DOS supplies an installable device driver, ANSI.SYS. This driver processes ANSI escape sequences that control cursor position and display modes such as color display and line wrapping. If ANSI.SYS has been loaded, programs can set the display mode by using Set Display Mode (Interrupt 21h Function 440Ch Minor Code 5Fh) and retrieve the current display mode by using Get Display Mode (Interrupt 21h Function 440Ch Minor Code 7Fh). Both functions require a pointer to a DISPLAYMODE structure that specifies the number of colors, columns, and rows available with the display mode.