所以我的任務是創建V由星號(*)製成,每個*有一個隨機的前景色和背景色。這裏是我的代碼...我放了幾個休息時間,並追溯了程序,並有點想出了它的問題。當我運行它時,它變成一個無限循環,因爲反斜槓PROC
調用覆蓋循環計數器(ECX
寄存器)的顏色過程,並且還覆蓋用於移動光標位置的寄存器DH
/DL
。我是一名初學者,可以使用一些提示或技巧來避免將來出現這些問題並加以解決。任何幫助表示感謝,提前致謝!裝配中的意外死循環
分配指導方針 - https://docs.google.com/document/d/1iPqfTd0qNOQo_xubVvsZLqfeNDog8mK6kzGGrR6s-OY/edit?usp=sharing
; main.asm - Assembly language source file
; Author: Dekota Brown
; Date: 2/21/2017
; Description: Colorful V-Pattern
INCLUDE Irvine32.inc ; Irvine's assembly library
ExitProcess PROTO,dwExitCode:DWORD ; MS Windows ExitProcess function
.data
nullVar DWORD ?
msgEnd BYTE "Is the program running as you thought?",0
msgEndCaption BYTE "Program Exit...",0
symbol BYTE '*',0
.code
main PROC ; main procedure, entry point
mov EAX, nullVar
mov EBX, nullVar
mov ECX, nullVar
mov EDX, nullVar
call backslash
mov EDX,OFFSET msgEnd
mov EBX,OFFSET msgEndCaption
call MsgBoxAsk
mov EAX,07
call SetTextColor
call CrLf
call WaitMsg
INVOKE ExitProcess,0 ; end the program
main ENDP
color PROC
call Randomize ; Seed the RNG
mov ECX,20 ; Set up loop counter
L1:
mov EAX, 256
call RandomRange
call SetTextColor
mov EDX,OFFSET symbol
call WriteString
loop L1
ret
color ENDP
backslash PROC
mov dl, 2 ; Row 2
mov dh, 4 ; Column 4
mov ECX,20 ; Sets up loop counter
L2:
call color
call CrLf
add dh,1 ; Increments column or shifts right by 1 position
loop L2
ret
backslash ENDP
forwardslash PROC
ret
forwardslash ENDP
END