home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / MOUSE / MSMOUSE1.ZIP / ASM.ZIP / ASMEXAMP.ASM next >
Encoding:
Assembly Source File  |  1989-02-10  |  3.8 KB  |  102 lines

  1. ;---------------------------------------------------------------
  2. ; Program:      ASMEXAMP.ASM
  3. ;
  4. ; Description:  Demonstrates Mouse Functions 0, 1, 2, 3, 4, 7,
  5. ;               and 8.  Displays graphics mode cursor and
  6. ;               checks for installation of the mouse driver.
  7. ;
  8. ; To Run:       MASM ASMEXAMP;
  9. ;               LINK ASMEXAMP;
  10. ;               ASMEXAMP
  11. ;---------------------------------------------------------------
  12.  
  13. data    segment public  'data'
  14.         msg0    db   "Mouse driver not installed","$"
  15.         msg1    db   "Mouse not found","$"
  16.         msg2    db   "Graphics cursor limit at center of the screen",0dh,0ah
  17.                 db   "Press the left mouse button to EXIT","$"
  18. data    ends
  19.  
  20. code    segment public  'code'
  21.         assume cs:code, ds:nothing, es:nothing
  22. start:
  23.         mov     ax,seg data             ;Set DS to the
  24.         mov     ds,ax                   ;data segment
  25.         assume  ds:data
  26.  
  27.         ; Check if mouse driver installed
  28.         mov     ax, 03533h              ;Get Int 33H vector
  29.         int     21h                     ;by calling Int 21H.
  30.         mov     ax, es                  ;Check segment and offset of
  31.         or      ax, bx                  ;Int 33H.  If 0 then driver
  32.         jz      not_installed           ;is not installed.
  33.         cmp byte ptr es:[bx], 0CFh      ;Also, if IRET then driver is
  34.         jne     check_mouse             ;not installed.
  35.  
  36. not_installed:
  37.         mov     dx, offset msg0         ;Message 0
  38.         mov     ah, 09h                 ;Output message to screen
  39.         int     21h
  40.         mov     ax, 4C01h               ;Exit
  41.         int     21h
  42.  
  43. check_mouse:
  44.         xor     ax, ax                  ;Initialize mouse
  45.         int     33h
  46.         or      ax, ax                  ;Is mouse installed?
  47.         jnz     mouse_ok                ;Then continue
  48.  
  49.         ; Mouse not found
  50.         mov     dx, offset msg1         ;Message 1
  51.         mov     ah, 09h                 ;Output message to screen
  52.         int     21h
  53.         mov     ax, 4C01h               ;Exit
  54.         int     21h
  55.  
  56. mouse_ok:
  57.         mov     ax,0006h                ;Set up for 640 x 200 resolution
  58.         int     10h                     ;graphics mode (CGA mode 6)
  59.  
  60.         mov     ax, 4                   ;Function 4
  61.         mov     cx, 200                 ;M3 = 200
  62.         mov     dx, 100                 ;M4 = 100
  63.         int     33h                     ;Set Mouse Cursor Position
  64.  
  65.         mov     ax, 7                   ;Function 7
  66.         mov     cx, 150                 ;M3 = 150
  67.         mov     dx, 450                 ;M4 = 450
  68.         int     33h                     ;Set Minimum and Maximum Horizontal
  69.                                         ;Cursor Position
  70.  
  71.         mov     ax, 8                   ;Function 8
  72.         mov     cx, 50                  ;M3 = 50
  73.         mov     dx, 150                 ;M4 = 150
  74.         int     33h                     ;Set Minimum and Maximum Vertical
  75.                                         ;Cursor Position
  76.  
  77.         mov     ax,1                    ;Show cursor
  78.         int     33h
  79.  
  80.         mov     dx, offset msg2         ;Get exit message
  81.         mov     ah, 09h                 ;Output message to screen
  82.         int     21h
  83.  
  84. around:
  85.         mov     ax, 3                   ;Function 3
  86.         int     33h                     ;Get Button Status and Mouse Position
  87.  
  88.         test    bx, 0001h               ;Left button pressed ?
  89.         jz      around                  ;Branch if left button NOT pressed
  90.  
  91.         xor     ax, ax                  ;Function 0
  92.         int     33h                     ;Mouse Reset and Status
  93.  
  94.         mov     ax, 0003h               ;Set up 80 x 25 character text mode
  95.         int     10h
  96.  
  97.         mov     ax,04C00h               ;Normal exit
  98.         int     21h
  99.  
  100. code    ends
  101. end     start
  102.