Write a program that displays the same string in four different colors,using a loop. Call the SetTextColor procedure.Any color may be chosen, but you may find it easiest to change the forground color.

Include irvine32.inc
.data
Str BYTE “This is the string”, 0
Color BYTE red,yellow,blue,cyan
.code
Main PROC 
Mov ecx,4
Mov edx,OFFSET color
L1:     
Mov eax,color+(black*16)    ;4 different colors on black background
Call SetTextColor
Call prompt
Call crlf
Inc  color
Loop L1
Exit
Main ENDP
;------------------------------------
Prompt PROC USES edx
;------------------------------------
Mov edx,OFFSET str
Call WriteString
Ret
Prompt ENDP
END main

My question is: Can I write the statement ,
Inc color
like this?
I have a slight confusion in it.

1: Is the compiler your using case sensitive? If so, color & Color are not the same
2: What is the calling conventions of SetTextColor? CDELC pushes value or pointer on stack
mov eax, [Color] + (black * 16)
push eax
call SetTextColor

You could also;

push dword [Color] + (black * 16)
call SetTextColor
inc Color                 ; Bump pointer

Brackets around Color denote you want to use the contents at that memory location, not the value of the pointer
Parentheses are not required as multiplication happens before division.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.