以下是代码:
proc ChangeColumnNumber1
inc [FirstColumnArray]
mov [Player1Drawx], 25h
mov [Player1Drawy], 87h
jmp DrawPlayer1Disc
endp ChangeColumnNumber1
DrawPlayer1Loop:
mov bh,0h
mov cx,[Player1Drawx]
mov dx,[Player1Drawy]
mov al,[player1disccolor]
mov ah,0ch
int 10h
inc [Player1Drawx]
cmp cx, [Player1Drawx + 14h]
jl DrawPlayer1Loop
DrawPlayer1Disc:
mov bh, 0h
inc [Player1Drawy]
cmp dx, [Player1Drawy + 14h]
jl DrawPlayer1Loop
proc CheckPlayer2Number
mov ah, 7
int 21h
cmp al, 31h
je Player2CheckColumn1
jmp CheckPlayer2Number
endp CheckPlayer2Number
proc Player2CheckColumn1
cmp [FirstColumnArray], 0
je ChangeColumnNumber2
cmp [FirstColumnArray + 1], 0
je ChangeColumnNumber2
endp Player2CheckColumn1
proc ChangeColumnNumber2
inc [FirstColumnArray + 1]
mov [Player2Drawx], 25h
mov [Player2Drawy], 60h
jmp DrawPlayer2Disc
endp ChangeColumnNumber2
DrawPlayer2Loop:
mov bh,0h
mov cx,[Player2Drawx]
mov dx,[Player2Drawy]
mov al,[player2disccolor]
mov ah,0ch
int 10h
inc [Player2Drawx]
cmp cx, [Player2Drawx + 14h]
jl DrawPlayer2Loop
DrawPlayer2Disc:
mov bh, 0h
inc [Player2Drawy]
cmp dx, [Player2Drawy + 14h]
jl DrawPlayer2Loop
当我执行它时,我应该按'1'。当我这样做时它应该绘制一个正方形,当我应该再次按'1'时,它不会绘制第二个正方形。我不明白为什么它不起作用。在此之前,我有一个mov命令,它将一个值移动到例如Player1Drawx中,但它不能用于我的新代码,所以我将其删除。
感谢您的帮助。
答案 0 :(得分:1)
proc ChangeColumnNumber1 inc [FirstColumnArray] mov [Player1Drawx], 25h mov [Player1Drawy], 87h jmp DrawPlayer1Disc endp ChangeColumnNumber1
当jmp DrawPlayer1Disc
未设置DX
注册时,您仍然可以立即在cmp dx, [Player1Drawy + 14h]
中使用它。
DrawPlayer1Disc:
mov bh, 0h
inc [Player1Drawy]
mov dx, [Player1Drawy] <<< Don't you need this?
cmp dx, [Player1Drawy + 14h]
jl DrawPlayer1Loop
ret <<< Aren't you missing a return here?
同样适用于 DrawPlayer2Disc 。