You are on page 1of 4

;display page

mov ah,1
mov ch,2bh
mov cl,0bh
int 10h
mov al,0
mov ah,05h
int 10h
;initial position of robot
;to print character at dx location
mov ah,02h
mov dx,0c25h
int 10h
;to save the position of dx
push dx
mov al,0001h
mov ah,09h
mov bl,0eh
mov cx,1
int 10h
;to initiate mouse harware n ol
mov ax,0000h
int 33h
;to show cursor
mov ax,0001h
int 33h
loopbig:
push dx
;to wait for the key
mov ax,0000h
int 16h
;to get the position of the mouse
mov ax,0003h
int 33h
mov si,dx
;to wait for the key
mov ax,0000h
int 16h
;giving bx a value of 8 as cx and dx are in pixels and 1 char=8 px
mov bx,0008h
;to move the value of cx in ax for the x direction
mov ax,cx
;to divide ax by bl i.e 8 to get quotient in al
div bl
;retrieve the value of dx i.e the position of bot
pop dx
;compare the column position of bot and mouse
cmp al,dl
;if dl is greater then goto label2
jz label1
; if dl is equal to al then goto label1
jc label2
;if al is greater than dl then perform this
loop11:
;push the value of ax basically to store al
push ax
;to print null at previous place

mov ah,02h
int 10h
mov al,0000h
mov ah,09h
mov bl,0eh
mov cx,1
int 10h
inc dx
;to print the block at new site
mov ah,02h
int 10h
mov al,0001h
mov ah,09h
mov bl,0eh
mov cx,1
int 10h
;retrieve the value of al for comparison
pop ax
cmp al,dl
;jump if the result of comparison is not yet 0
jne loop11
jmp label1
label2:
loop122:
;push the value of ax basically to store al
push ax
;to print null at previous place
mov ah,02h
int 10h
mov al,0000h
mov ah,09h
mov bl,0eh
mov cx,1
int 10h
dec dx
;to print the block at new site
mov ah,02h
int 10h
mov al,0001h
mov ah,09h
mov bl,0eh
mov cx,1
int 10h
;retrieve the value of al for comparison
pop ax
cmp al,dl
;jump if the result of comparison is not yet 0
jne loop122
label1:
push dx
;giving bx a value of 8 as cx and dx are in pixels and 1 char=8 px
mov bx,0008h
;to move the value of dx in ax for the y direction
mov ax,si
;to divide ax by bl i.e 8 to get quotient in al
div bl
;retrieve the value of dx i.e the position of bot
pop dx
;compare the row position of bot and mouse

cmp al,dh
;if dl is greater then goto label2
jz label111
; if dl is equal to al then goto label1
jc label21
;if al is greater than dl then perform this
loop112:
;push the value of ax basically to store al
push ax
;to print null at previous place
mov ah,02h
int 10h
mov al,0000h
mov ah,09h
mov bl,0eh
mov cx,1
int 10h
inc dh
;to print the block at new site
mov ah,02h
int 10h
mov al,0001h
mov ah,09h
mov bl,0eh
mov cx,1
int 10h
;retrieve the value of al for comparison
pop ax
cmp al,dh
;jump if the result of comparison is not yet 0
jne loop112
jmp label111
label21:
loop118:
;push the value of ax basically to store al
push ax
;to print null at previous place
mov ah,02h
int 10h
mov al,0000h
mov ah,09h
mov bl,0eh
mov cx,1
int 10h
dec dh
;to print the block at new site
mov ah,02h
int 10h
mov al,0001h
mov ah,09h
mov bl,0eh
mov cx,1
int 10h
;retrieve the value of al for comparison
pop ax
cmp al,dh
;jump if the result of comparison is not yet 0
jne loop118
label111:
jmp loopbig

You might also like