2011-12-22 79 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