-1

Here is the code:

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

When I execute it I am supposed to press '1'. When I do that it is supposed to draw a square and when I am supposed to press '1' again, it doesn't draw the second square. I don't understand why it doesn't work. Before that I had a mov command which moves a value into, for example, Player1Drawx but it won't work with my new code so I deleted it.

Thanks for any help I get.

Cœur
  • 37,241
  • 25
  • 195
  • 267
KatomPower
  • 119
  • 1
  • 3
  • 14
  • Use a debugger and comment your code, especially if you want others to help. Also provide proper [MCVE]. – Jester Jun 12 '16 at 15:05

1 Answers1

1
proc ChangeColumnNumber1
    inc [FirstColumnArray]
    mov [Player1Drawx], 25h
    mov [Player1Drawy], 87h
    jmp DrawPlayer1Disc
endp ChangeColumnNumber1

When you jmp DrawPlayer1Disc the DX register was not setup, still you immediately use it in 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?

The same applies to DrawPlayer2Disc.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76