Also meine Aufgabe besteht darin, V aus Sternchen (*) zu erstellen, wobei jedes * eine zufällige Vorder- und Hintergrundfarbe hat. Hier ist mein Code ... Ich habe ein paar Pausen eingelegt und das Programm verfolgt und etwas herausgefunden, was das Problem ist. Wenn ich es ausführe, wird es zu einer Endlosschleife, weil der Backslash PROC
die Farbe Prozedur aufruft, die den Schleifenzähler (ECX
Register) überschreibt und auch die DH
/DL
Register, die zum Verschieben der Cursorposition verwendet werden, überschreibt. Ich bin ein Anfänger in der Assembly und könnte ein paar Tipps oder Tricks verwenden, um diese Probleme in Zukunft zu vermeiden und zu beheben. Jede Hilfe wird geschätzt, danke im Voraus!Unbeabsichtigte Endlosschleife in Assembly
Zuteilung Leitlinien - 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