; Mouse manipulations.  left-click X , right-click O. After clicking
; the mouse, you need to hit any key, in order to enable the mouse to
; click again.

IDEAL
MODEL small
STACK 100h
DATASEG
lastc         db   ? 
CODESEG

start:        mov ax, @data
              mov ds, ax
;graphics mode
              mov  ax,13h
              int  10h
;Init mouse
              mov  ax,0h
              int  33h
;Show mouse
              mov  ax,1h
              int  33h                                         
 
; Wait for key press
;              mov  ah,00h  
;              int  16h 
 
 
;Loop until  mouse clicked  

                   
mousecl:      xor  bx,bx           
              mov  ax,3h
              int  33h
              cmp  bx,01h  
              je   paintx   ; left-click
              cmp  bx,02h
              je   painto   ; right-click
              jmp  mousecl       
;print x
paintx:
              mov ah,2
              mov dl, 'X'
              int 21h
              mov [lastc],'X'
              ; Wait for key press
              mov  ah,00h  
              int  16h 

	          jmp  mousecl
;print o
painto:       mov ah,2
              mov dl, 'O'
              int 21h 
              mov [lastc],'O'
              ; Wait for key press
              mov  ah,00h  
              int  16h                                          
              jmp mousecl
              
stop:         mov  ax,3h
              int  10h               
                         
exit:         mov  ax, 4c00h
              int  21h
END start   