Chapter 5
Procedures
Assembly Language Programming Exercise
Problem # 1:
Write a program that displays the same string in four different colors, using a loop. Call the SetTextColor procedure from the book’s link library. Any colors may be chosen, but you may find it easiest to change the foreground color.
Solution:
INCLUDE Irvine32.inc
.data
str1 BYTE "This is a coloured string.",0
.code
main PROC
MOV ECX, 4
MOV EAX, green + (white*16)
MOV EDX, OFFSET str1
L1:
call SetTextColor
call WriteString
call Crlf
INC EAX
LOOP L1
call WaitMsg
exit
main ENDP
END main
.data
str1 BYTE "This is a coloured string.",0
.code
main PROC
MOV ECX, 4
MOV EAX, green + (white*16)
MOV EDX, OFFSET str1
L1:
call SetTextColor
call WriteString
call Crlf
INC EAX
LOOP L1
call WaitMsg
exit
main ENDP
END main
Let me know in the comment section if you have any question.
Previous Post:
Program to Reverse an Array in Assembly Language using Visual Studio
Previous Post:
Program to Reverse an Array in Assembly Language using Visual Studio