2011-12-22 86 views
2

我与装配玩弄,编译为.COM使用NASM在Windows 7中由于某种原因的文件,这不起作用:鼠标与ASM INT 33H不工作

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一样。然后,程序应该退出。但是,当我执行程序时,它只等待一次鼠标点击。 我需要做些什么来解决这个问题? 在此先感谢

+3

good ol'DOS,:) – 2011-12-22 17:25:03

回答

4

我相信这会做到(有评论)。
代码未经测试

基本上,现在有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) 
+0

+1代码:-) – 2011-12-22 19:42:30

4

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

+0

这样做的最佳方法是什么?我不认为int15h ah86h BIOS等待功能可以在Windows 7上工作。 – user1112148 2011-12-22 17:25:18

+0

实验只是按照等待按下状态的方式进行。 – 2011-12-22 17:27:58