I'm attempting to add two numbers together, and then print resultMsg
in 4 different colors as mentioned in colors
.
Code:
INCLUDE Irvine32.inc
.data
prompt1 BYTE "Please type your first integer:", 0dh, 0ah, 0
prompt2 BYTE "Please type your second integer:", 0dh, 0ah, 0
resultMsg BYTE "The sum is ", 0
colors BYTE yellow, blue, red, green
.code
main PROC
call clrscr
call InteractiveSum
mov eax, 5000
call Delay
exit
main ENDP
InteractiveSum PROC
mov edx,OFFSET prompt1
call WriteString
call ReadInt
mov ebx,eax
call Crlf
mov edx, OFFSET prompt2
call WriteString
call ReadInt
add eax, ebx
mov edx, OFFSET resultMsg
call WriteString
call WriteInt
ret
InteractiveSum ENDP
END main
I'm using the Irvine32.inc library, and was researching the SetTextColor feature. It looks like it would be perfect for what I'm trying to do here but in the example...
.data
str1 BYTE "Color output is easy!",0
.code
mov eax,yellow + (blue * 16)
call SetTextColor
mov edx,OFFSET str1
call WriteString
call Crlf
it appears that the color has to be put into eax
, and thats where my sum of the two numbers is stored since it has to be stored there for WriteInt
if I am correct? Is there a work around for this?