How do I write text in DOS, setting each character to a different colour?
You can use ANSI escape codes like described in this question which was basically the same question for C++. This answer should show clearly how to use the escape codes.
Depends on your programming language.
You can do this from a batch file:
- Add ansi.sys to your config.sys
- Write text using the appropriate ANSI escape codes
Your question isn't very clear, but if you're trying write text in different colours to a terminal, ANSI escape codes are what you want to look at.
Do you really want to do this in assembly? (as per your tag)
You can use Function 10H Subfunction 10h
ah = 10h
al = 10h
bx = color register
ch = green
cl = blue
dh = red
I type the funcion because its marked with assemply, how ever you need to have the full book of all that functions on DOS.
As an alternative to the already suggested methods (1. using ansi.sys
, or 2. using interrupt 10h), if you are using a CGA card or a video card in CGA-compatible text mode, the video buffer is at address 0xB800 and you can write directly there. Each character on screen is represented by two bytes in the buffer, the first being the ASCII code of the character and the second the video attribute of the character (foreground color—4 bits, background color—3 bits and (horror) a blinking bit).