0

I am using a procedure in TASM that waits for a left click from the mouse, and then exits. When debugging, the problem appears to work fine in the first time but from the second time on the previous values are reused for no visible reason. Does anyone have any ideas? Thanks!

Here is the code of the function:

proc WaitForLeftClick
ContinueWaitForLeftClick:

    mov ax, 3
    int 33h
    and bx, 00000001b
    jnz ExitWaitForLeftClick    
    jmp ContinueWaitForLeftClick
ExitWaitForLeftClick:
    ret
endp WaitForLeftClick

The problem appears when debugging the following part:

Valid_Press:
    cmp [First_Round], 0
    je Skip_Plus_Two ; the first round variable is to determine if the first card on pile was discard card
    cmp [Last_Value], -4 ; check for +2
    je Check_For_Two
Skip_Plus_Two:
    mov [First_Round], 1 ; change it to one so it works only once
    xor ax, ax
    call WaitForLeftClick ; first wait for left click
Clicked:
    shr cx, 1 ; actual x
    ; check for draw 
    cmp dx, 70
    jb Maybe_Card
    cmp dx, 120
    ja Maybe_Card
    ; now cmp x
    cmp cx, 30
    jb Maybe_Card
    cmp cx, 60
    ja Maybe_Card
    ; if all conditions not reached, press was on picture
    jmp Draw_One_Card   
    
Maybe_Card:
    push [Interval] ; interval
    push dx
    push cx
    call Is_On_Card ; check for press on card
        
    cmp ax, 0FFFFh ; the check
    je Press_Is_Card    
    xor bx, bx
    xor cx, cx
    xor dx, dx
    jmp Valid_Press ; input not card
Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82
  • 2
    This isn't an [mcve]. The problem is likely elsewhere or something else interfering. Note: You could simplify the loop by just using `jz ContinueWaitForLeftClick`. If its not zero it just falls through and exits automatically. – Michael Petch Jun 08 '22 at 19:26
  • 1
    "...the previous values are reused..." Do you mean CX (horizontal position) and DX (vertical position) don't change even if you move the mouse? – Sep Roland Jun 08 '22 at 20:58
  • 1
    Maybe https://stackoverflow.com/questions/53596362/assembly-get-mouse-position-tasm can help? Also, somehow I seem to remember that this was an issue related to the TASM debugger. Can't find the reference though... Does the problem persist if you run the program normally, so not while debugging? – Sep Roland Jun 08 '22 at 21:14
  • @SepRoland When running the code it works completely fine, which makes me think the problem is in the debugger. The problem, however, makes my code difficult to debug as I can't progress more than a constant distance.. – ThErOmAnEmPiRe Jun 09 '22 at 10:06
  • I don't see where your code for `Check_For_Two` is. Maybe the branch `je Check_For_Two` is always being taken which skips your `call WaitForLeftClick`? – puppydrum64 Dec 15 '22 at 14:39

0 Answers0