I'm going to offer one way of achieving this with DOS int 21h
.
The original poster says they are using TASM 1.4(TASM installer), which is a DOSBox based environment with TASM 3.0 and Turbo Debugger 3.1. In the days of DOS there was a video console driver that could be added to CONFIG.SYS
with a command like DEVICE=C:\DOS\ANSI.SYS
. This driver enhanced DOS int 21h
output so you could specify attributes(background color, foreground color, blinking); clear the screen; reset back to default (usually black on white). DOSBox has a partial implementation of ANSI.SYS built in. The following code takes advantage of these ANSI codes:
.model small
.stack 100h
.data
a_cls db 27, "[2J$" ; Clear entire screen in currently set attributes
a_reset db 27, "[0m$" ; Reset attributes to standard (black on white)
a_blink db 27, "[5m$" ; Characters blink (blink doesn't work in all environments)
a_bright db 27, "[1m$" ; Bright colored characters
a_dim db 27, "[2m$" ; Dim colored characters
a_fg_black db 27, "[30m$" ; Foreground colors
a_fg_red db 27, "[31m$"
a_fg_green db 27, "[32m$"
a_fg_yellow db 27, "[33m$"
a_fg_blue db 27, "[34m$"
a_fg_magenta db 27, "[35m$"
a_fg_cyan db 27, "[36m$"
a_fg_white db 27, "[37m$"
a_bg_black db 27, "[40m$" ; Background colors
a_bg_red db 27, "[41m$"
a_bg_green db 27, "[42m$"
a_bg_yellow db 27, "[43m$"
a_bg_blue db 27, "[44m$"
a_bg_magenta db 27, "[45m$"
a_bg_cyan db 27, "[46m$"
a_bg_white db 27, "[47m$"
text1 db "Blinking Bright Yellow on Blue$"
text2 db " Back to Normal$"
text3 db " Bright Yellow on Black$"
combined db 27, "[0;5;2;31;42m Blinking Dim Red on Green$"
.code
begin:
mov ax,@data
mov ds,ax
mov es,ax
mov ah,09h
lea dx,a_cls ; clear screen
int 21h
lea dx,a_bright ; Bright colored characters
int 21h
lea dx,a_blink ; make the characters blink (if supported)
int 21h
lea dx,a_fg_yellow; make the characters yellow
int 21h
lea dx,a_bg_blue ; blue background for characters
int 21h
lea dx,text1 ; print text
int 21h
lea dx,a_reset ; reset to defaults
int 21h
lea dx,text2 ; print normal text
int 21h
lea dx,a_bright ; bright characters
int 21h
lea dx,a_fg_yellow; make the characters yellow
int 21h
lea dx,text3 ; print text
int 21h
lea dx,combined ; print combined text
int 21h
lea dx,a_reset ; reset to defaults before exiting back to DOS prompt
int 21h
.exit
end begin
In DOS, ANSI codes start with the ESCAPE character (decimal 27) followed by [ (left bracket). For attributes the m command can be used. Attributes can be separated by semi-colons. There are some other commands besides m and they can be found in the ANSI specs. If you review the code above you'll see where I have broken out the ANSI codes for a number of commands that may be of interest to the original poster.
The following code is an example of combining a number of attributes (using ANSI) rather than doing them separately.
combined db 27, "[0;5;2;31;42mBlinking Dim Red on Green$"
Broken out we start with ESCAPE [ . 0 resets the current attributes to default (most hardware is white on black). The rest of the attributes are separated by SEMI COLONS. The next attribute 5 is blinking, the next is 2 which is dimmed color, 31 is foreground color red, 42 is green background followed by the command m . m ends the command and the characters after are the text to print.
Based on the escape sequences in the previous code, the following would fulfill the specific question the poster asked:
.model small
.stack 100h
.data
a_reset db 27, "[0m$" ; Reset attributes to standard (black on white)
; 13, 10 is carriage return line feed combination(CR/LF)
line1 db 27, "[1;32mHi, what group would you like to join?", 13, 10, "$"
line2 db 27, "[1;34mThe Founders", 13, 10, "$"
line3 db 27, "[1;31mThe Vox Populi", 13, 10, "$"
line4 db 27, "[1;5;31;47mand maybe I'd want another sentence that blinks?$"
.code
begin:
mov ax,@data
mov ds,ax
mov es,ax
mov ah,09h
lea dx,line1 ; print line 1 (bright green)
int 21h
lea dx,line2 ; print line 2 (bright blue)
int 21h
lea dx,line3 ; print line 3 (bright red)
int 21h
lea dx,line4 ; print line 4 (blinking bright red on white background)
int 21h
lea dx,a_reset ; reset colors back to default before exiting
int 21h
.exit
end begin
Blinking is known to work in DOSBox, VMWare, Bochs, but doesn't work in emu8086, and Windows NT+ DOS prompt.
In a previous set of comments in this posters other related question I did suggest the alternative is to write a procedure or function that takes a string and uses DOS interrupts and/or BIOS interrupts to change the attributes on a character by character basis and display them to the screen (while keeping track of the cursor). The most efficient way is to directly write the attributes to video memory (ie 0xb000:0). The ANSI.SYS method above I have used is the easiest to get going, and should work by default in modern versions of DOSBox.