tags:

views:

172

answers:

5

How do I write text in DOS, setting each character to a different colour?

+1  A: 

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.

hlovdal
+3  A: 

Depends on your programming language.

You can do this from a batch file:

  1. Add ansi.sys to your config.sys
  2. Write text using the appropriate ANSI escape codes
Tim Robinson
A: 

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)

therefromhere
ANSI escape codes work in assembly too ;)
Tim Robinson
Sure, but given the state of the rest of the question I thought it was worth asking.
therefromhere
+1  A: 

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.

Aristos
I think by "bc" you mean "bx".
PhiS
+2  A: 

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).

Pascal Cuoq