2
我試圖將兩個數字加在一起,然後用colors
中提到的4種不同顏色打印resultMsg
。裝配:以不同顏色打印一條線
代碼:
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
我使用Irvine32.inc庫,並研究了SetTextColor功能。看起來這將是完美的什麼,我想在這裏做的,但在本例中......
.data
str1 BYTE "Color output is easy!",0
.code
mov eax,yellow + (blue * 16)
call SetTextColor
mov edx,OFFSET str1
call WriteString
call Crlf
看起來顏色已投入eax
,和多數民衆贊成在我的兩個之和如果我是正確的,那麼數字將被存儲在WriteInt
中?有沒有解決這個問題的方法?