【问题标题】:mouse with int 33h in ASM not workingASM 中 int 33h 的鼠标不起作用
【发布时间】:2012-01-26 07:20:08
【问题描述】:

我在玩汇编,在 Windows 7 上使用 NASM 编译为 .com 文件。由于某种原因,这不起作用:

org 100h
run1:
mov ax, 3
int 33h
cmp bx, 0
je run1
xor bx, bx
run2:
mov ax, 3
int 33h
cmp bx, 0
je run2
int 20h

我认为这应该重复 run1 直到有鼠标点击,然后对 run2 做同样的事情。然后,程序应该退出。但是,当我执行程序时,它只等待一次鼠标单击。 我需要做什么来解决这个问题? 提前致谢

【问题讨论】:

    标签: assembly mouse nasm dos interrupt


    【解决方案1】:

    问题是鼠标按钮按住了一段时间。因此,在run1 之后,您需要等待按钮再次释放,然后您才能再次开始检查第二次点击。

    【讨论】:

    • 最好的方法是什么?我不认为 int15h ah86h BIOS 等待功能适用于 windows 7。
    • 对于实验,只需按照等待按下状态的方式进行。
    【解决方案2】:

    我相信这会做到(使用 cmets)。
    代码未经测试

    基本上,现在有 3 个循环。
    1.) 等待按钮被按下。
    2.) 等待按钮被释放。
    3.) 等待再次按下按钮。

    org 100h
    run1:
    mov ax, 3
    int 33h     #Check the mouse
    cmp bx, 0   #See if button is pressed
    je run1     #If Not pressed, go back and check again
    
    xor bx, bx  #Okay, button is pressed, clear the result
    
    run1a:
    mov ax, 3
    int 33h     #Check the mouse
    cmp bx, 0   #See if button is released
    jne run1a   #If NOT equal, then not released, go check again.
    
    xor bx, bx  #button is released, clear the result
    
    run2:
    mov ax, 3
    int 33h     #Check the mouse
    cmp bx, 0   #if button is pressed (2nd time)
    je run2     #If NOT pressed, go to top.
    
    int 20h     #Button was pressed.  All done (we don't care when its released)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 2015-08-08
      • 1970-01-01
      • 2013-01-30
      相关资源
      最近更新 更多