Amirhossein Sharifloo
Amirhossein Sharifloo

Reputation: 55

Assembly emulator doesn't support int33h function 05

Right now I'm using emu8086 to do an assembly project for a course. I'm writing a program to record how many times a mouse button has been clicked and if the right click has been tapped for three times, program would be ended. This could be done by function 05 if INT33h in 8086 assembly; but this emulator apparently doesn't support this. have you guys any suggestions to do this in another way?

that part of code is this:

 MOV   AX,05H                     ;GetS Button Press Information
    INT   33H               


    CMP   AX,2
    JE    COUNTRC
    ;MOV   RCCNT, 0 

COUNTRC:        
    ADD RCCNT, BX     ;  BX = number of button presses on specified button
                    ; CX = horizontal position at last press
                      ; DX = vertical   position at last press       
    CMP   RCCNT,3
    JE    EXIT

Upvotes: 0

Views: 1033

Answers (1)

AX=5 returns the state of a specific button, or you can use AX=3 to get the state of the mouse, including buttons pressed and the X,Y position. Next code displays one message when left button is clicked and another message when right button is clicked, copy-paste it in EMU and run it :

.model small
.stack 100h
.data

left  db 'LEFT BUTTON PRESSED',13,10,'$'
right db 'RIGHT BUTTON PRESSED',13,10,'$'

.code
  mov  ax, @data
  mov  ds, ax

  mov  ax, 0     ;◄■■ START MOUSE.
  int  33h

  mov  ax, 1     ;◄■■ DISPLAY MOUSE CURSOR.
  int  33h  

while:  ;◄■■ REPEAT UNTIL A KEY IS PRESSED.                   
;GET MOUSE STATE.
  mov  ax, 3
  int  33h    ;◄■■ STATE RETURNS IN BX.
;CHECK LEFT BUTTON STATE.
  mov  ax, bx  ;◄■■ PRESERVE BX.
  and  ax, 0000000000000001b ;◄■■ BIT 0 : LEFT BUTTON.
  jz   check_right  ;◄■■ IF BIT 0 == 0 : NO LEFT BUTTON.
  mov  ah, 9      ;◄■■ DISPLAY "LEFT BUTTON PRESSED"
  lea  dx, left
  int  21h
check_right:
;CHECK RIGHT BUTTON STATE.
  mov  ax, bx  ;◄■■ PRESERVE BX.
  and  ax, 0000000000000010b ;◄■■ BIT 1 : RIGHT BUTTON.
  jz   check_key  ;◄■■ IF BIT 1 == 0 : NO RIGHT BUTTON.
  mov  ah, 9      ;◄■■ DISPLAY "RIGHT BUTTON PRESSED"
  lea  dx, right
  int  21h
check_key:
;CHECK IF A KEY WAS PRESSED.
  mov  ah, 0bh
  int  21h                                     
  cmp  al, 0       ;◄■■ AL==0 : NO KEY.
  jz   while

  mov  ax, 4c00h   ;◄■■ FINISH PROGRAM.
  int  21h

You can modify this code to add counters to control how many times each button is pressed.

Upvotes: 2

Related Questions