home *** CD-ROM | disk | FTP | other *** search
- ;---------------------------------------------------------------
- ; Program: ASMEXAMP.ASM
- ;
- ; Description: Demonstrates Mouse Functions 0, 1, 2, 3, 4, 7,
- ; and 8. Displays graphics mode cursor and
- ; checks for installation of the mouse driver.
- ;
- ; To Run: MASM ASMEXAMP;
- ; LINK ASMEXAMP;
- ; ASMEXAMP
- ;---------------------------------------------------------------
-
- data segment public 'data'
- msg0 db "Mouse driver not installed","$"
- msg1 db "Mouse not found","$"
- msg2 db "Graphics cursor limit at center of the screen",0dh,0ah
- db "Press the left mouse button to EXIT","$"
- data ends
-
- code segment public 'code'
- assume cs:code, ds:nothing, es:nothing
- start:
- mov ax,seg data ;Set DS to the
- mov ds,ax ;data segment
- assume ds:data
-
- ; Check if mouse driver installed
- mov ax, 03533h ;Get Int 33H vector
- int 21h ;by calling Int 21H.
- mov ax, es ;Check segment and offset of
- or ax, bx ;Int 33H. If 0 then driver
- jz not_installed ;is not installed.
- cmp byte ptr es:[bx], 0CFh ;Also, if IRET then driver is
- jne check_mouse ;not installed.
-
- not_installed:
- mov dx, offset msg0 ;Message 0
- mov ah, 09h ;Output message to screen
- int 21h
- mov ax, 4C01h ;Exit
- int 21h
-
- check_mouse:
- xor ax, ax ;Initialize mouse
- int 33h
- or ax, ax ;Is mouse installed?
- jnz mouse_ok ;Then continue
-
- ; Mouse not found
- mov dx, offset msg1 ;Message 1
- mov ah, 09h ;Output message to screen
- int 21h
- mov ax, 4C01h ;Exit
- int 21h
-
- mouse_ok:
- mov ax,0006h ;Set up for 640 x 200 resolution
- int 10h ;graphics mode (CGA mode 6)
-
- mov ax, 4 ;Function 4
- mov cx, 200 ;M3 = 200
- mov dx, 100 ;M4 = 100
- int 33h ;Set Mouse Cursor Position
-
- mov ax, 7 ;Function 7
- mov cx, 150 ;M3 = 150
- mov dx, 450 ;M4 = 450
- int 33h ;Set Minimum and Maximum Horizontal
- ;Cursor Position
-
- mov ax, 8 ;Function 8
- mov cx, 50 ;M3 = 50
- mov dx, 150 ;M4 = 150
- int 33h ;Set Minimum and Maximum Vertical
- ;Cursor Position
-
- mov ax,1 ;Show cursor
- int 33h
-
- mov dx, offset msg2 ;Get exit message
- mov ah, 09h ;Output message to screen
- int 21h
-
- around:
- mov ax, 3 ;Function 3
- int 33h ;Get Button Status and Mouse Position
-
- test bx, 0001h ;Left button pressed ?
- jz around ;Branch if left button NOT pressed
-
- xor ax, ax ;Function 0
- int 33h ;Mouse Reset and Status
-
- mov ax, 0003h ;Set up 80 x 25 character text mode
- int 10h
-
- mov ax,04C00h ;Normal exit
- int 21h
-
- code ends
- end start
-