ALP to MOUSE KEYBOARD INTERFACE
ALP to MOUSE KEYBOARD INTERFACE
divi macro number ;macro for number
mov ax,bx
mov dx,0000h
mov bx,number
div bx
mov bx,dx
mdov dx,ax
endm
dd
ddisp macro msg ;macro for message
lea dx,msg
mov ah,09h
int 21h
endm
.model small ;beginning of the program
.data ;initializing the data segment
msg1 db 10,13,"mouse interfacing supporting :$"
msg2 db 10,13,"mouse interfacing Not supporting :$"
msg3 db 10,13,"Keyboard interfacing supporting :$"
msg4 db 10,13,"keyboard interfacing Not supporting :$"
number dw 0000h
x dw 0000h
y dw 0000h
.code ;initialize the code segment
mov ax,@data
mov ds,ax
;print '.'
mov ah,02h
mov dh,10h ;y-coordinate
mov dl,29h ;x-coordinate
mov bh,00h ;page no
int 10h
mov ah,0eh ;to print the character at current cursor position
mov al,'.' ;get character dot in al
mov bh,00h ;page no
mov bl,02h ;foreground colour
int 10h
;print '*'
mov ah,02h
mov dh,00h ;y-coordinate
mov dl,4fh ;x-coordinate
mov bh,00h ;page no
int 10h
mov ah,0eh ;to print the character at current cursor position
mov al,'*' ;get character star in al
mov bh,00h ;page no
mov bl,02h ;foreground colour
int 10h
mov ax,0000h ;checking for mouse support is available
int 33h
cmp ax,0FFFFh
je l1
disp msg2
jmp exit
l1:disp msg1
mov ax,0001h ;dos function for show pointer
int 33h
z : call mouse ;(x,y coordinates)call mouse procedure
k:mov ah,0bh ;dos function for keyboard interface
int 21h
cmp al,00h
je z
l3:mov ah,00h ;dos function to read a character from keyboard
int 16h
cmp al,'h'
jne l4
mov ax,0002h ;function to hide the mouse pointer
int 33h
jmp l3
l4:cmp al,'s'
jne l5
mov ax,0001h ;function to show the mouse pointer
int 33h
jmp l3
l5:cmp al,'q'
je exit
exit:mov ah,4ch ;termination
int 21h
proc mouse near
mov ax,0003h ;funtion to get the mouse position and button status
int 33h
mov x,cx ;move cursor coordinates in x & y variables resp.
mov y,dx
;defining locus points for beep generation
cmp cx,10Ah ;10Ah is hex eq of 266 bcd no
jc next
cmp dx,6Fh ;6Fh is hex eq of 111 bcd no
jc next
cmp cx,1AFh ;1AFh is hex eq of 431 bcd no
jnc next
cmp dx,0A2h ;0A2h is hex eq of 162 bcd no
jnc next
call beeps ;call beeps procedure
next:mov ah,02h ;dos fun for int 10h to set the cursor position
mov bh,00h ;page no
mov dl,10h ;x- coordinate
mov dh,10h ;y-coordinate
int 10h
mov bx,x
call hex_to_bcd ;call hex to bcd procedure for printing x-coordinate
mov dl,':'
mov ah,02h ;print ':'
int 21h
mov bx,y
call hex_to_bcd ;call hex to bcd procedure for printing y-coordinate
ret
endp
proc hex_to_bcd near
divi 03e8h
call bcddisplay
divi 0064h
call bcddisplay
divi 000ah
call bcddisplay
divi 0001h
call bcddisplay
ret
endp
proc bcddisplay near
and dl,0fh
cmp dl,09h
jbe a
add dl,07h
a:add dl,30h
mov ah,02h
int 21h
ret
endp
proc beeps near
mov dl,07h ;07h is the ascii eq of beep
mov ah,02h
int 21h
call delay ;call delay procedure
ret
endp
proc delay near
mov cx,3000h
t:dec cx
jnz t
ret
endp
end
0 comments:
Post a Comment