
![]()
One of the newer I/O devices to take the personal computer market by storm in the past few years if the mouse. The mouse is an I/O device that replaces the cumbersome arrow keys on a keyboard for graphical and text style programs. A trackball is a variation of this device that functions and is programmed identically to a mouse except it is fixed, where the mouse rolls along a surface.
This experiment shows how to add the mouse to applications through a series of macros that enable and allow the mouse to function and keep track of the mouse position.
This experiment tests for the presence of the mouse, reads the mouse position, and tests the mouse buttons. Once completed, this experiment allows the inclusion of mouse software in virtually any application.
The mouse is accessed through the INT 33H instruction. Before the mouse can be used in a program, it must be known if the mouse is connected to the system and if it is enabled and functioning. To detect the presence of the mouse and enable it for use the following steps are required:
A macro is ideal to test to see if the mouse is present. Such a macro (_MP) appears in Example 14-1. The _MP macro detects a mouse and ends with carry = 0 if a mouse is present. If a mouse is not present, a message is displayed and carry = 1.
_MP MACRO ;is mouse present?
LOCAL M1,M2,M3
PUSH ES ;;save ES
MOV AX,3533H ;;read vector 33H
INT 21H
MOV AX,ES
OR AX,BX ;;test for ES:BX = 0
JZ M2 ;;if not, end macro
CMP BYTE PTR [BX],0CFH
JZ M2 ;;if not, end macro
MOV AX,0 ;;start mouse
INT 33H
OR AX,AX
JZ M2 ;;no mouse
CLC ;;if mouse, carry = 0
JMP M3
M1 DB 13,10,'*** NO MOUSE PRESENT ***$'
M2: PUSH DS
MOV AX,CS
MOV DS,AX
_STRING M1 ;;show no mouse
POP DS
STC ;;if no mouse, carry = 1
M3: POP ES
ENDM
![]()