8086 assembly right mouse click interrupts

依然范特西╮ 提交于 2019-12-01 09:56:15

问题


I am working on a project in 8086 assembly on windows machine and I need to know which mouse button has been clicked. What are the interrupts for this? or how do I go about finding this out?

Thanks


回答1:


If you're making a DOS program that runs under windows, you can use software interrupt 0x33, function 3, which returns the button status in the BL register :

    mov   ax,0x3
    int   0x33
    test  bl,1
    jnz   left_button_pressed
    test  bl,2
    jnz   right_button_pressed

More info here http://www.ctyme.com/intr/rb-5959.htm

If you're making a native Windows application, you can test for button presses by checking for the standard mouse button messages (WM_LBUTTONDOWN/UP , WM_RBUTTONDOWN/UP , WM_MBUTTONDOWN/UP) passed to your registered WndProc for the main window created by your program.

The function declaration for the WndProc is "LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);", the message type is passed in uMsg, so you'd check the DWORD at [esp+12] and compare it with the message ID you want to handle.




回答2:


On a "DOS" machine, look into Software Interrupt 0x33.
Command AH = 0x03 returns the mouse button pressed in register CX (along with mouse coordinates and other info, in other registers).

If available, it is of course much easier to user the Windows API for this purpose, as indicated in matja's answer.



来源:https://stackoverflow.com/questions/2418737/8086-assembly-right-mouse-click-interrupts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!