次のプログラムのポイントは、すべての背景色と前景色の組み合わせで文字「c」を出力することです。
私が使用しているライブラリでは、色は0〜15で定義されており、次のコードを使用しています。
mov eax,FOREGROUND + (BACKGROUND * 16)
call SetTextColor
これが私のコードです:
INCLUDE Irvine32.inc
.data
character BYTE "c"
count DWORD ?
background DWORD 0
.code
main PROC
call Clrscr
mov ecx, 15 ; our main counter 0-15 colors
L1:
mov count, ecx ; store our outer loop counter
mov ecx, 15 ; set out inner loop counter
L2:
; since our color is defined like so... mov eax,FOREGROUND + (BACKGROUND * 16)
mov eax, count ; setup our foreground color
add eax, background ; setup our background color
call SetTextColor
; instead of multiplying each background color by 16, we are going to
; add 16 each time.
add background, 16
; print the character
mov edx, OFFSET character
call WriteString
loop L2
mov ecx, count ; reset our outside loop
loop L1
call Crlf
exit
main ENDP
END main
現在、私はWindows 7を使用しています。上記のコードは「機能します」が、何らかの理由で特定のポイントに到達し、プログラムが停止し、コンピューターがビープ音を鳴らし始めます。また、プログラムのある時点で、文字 c.. でランダムな文字の出力を開始します。ここに私の出力があります:
c♀c♀c♀c♀c♀c♀c♀c♀c♀c♀c♀c♀c♀c♀c♀c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂c♂c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c c c c c c c c c c
c c c c c cccccccccccccccc♠c♠c♠c♠c♠c♠c♠c♠c♠c♠c♠c♠c
♠c♠c♠c♣c♣c♣c♣c♣c♣c♣c♣c♣c♣c♣c♣c♣c♣c♣c♦c♦c♦c♦c♦c♦c♦c♦c♦c♦c♦c♦c♦c♦c♦c♥c♥c♥c♥c♥c♥c♥c
♥c♥c♥c♥c♥c♥c♥c♥c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☻c☺c☺c☺c☺c☺c☺c☺c☺c☺c☺c☺c☺c☺c☺c☺
Press any key to continue . . .
なぜこれが起こっているのか誰にも教えてもらえますか?