// Cursor operations-Change size and Move//
print macro msg
lea dx,msg
mov ah,09h
int 21h
endm
.model small
.stack 100h
.data
msg1 db 10,13,'Press 1 to increase and 0 to decrease the size of cursor (only 4 sizes, initially minimum) $'
msg2 db 10,13,'Press 8,2,4 and 6 to move the cursor up,down,left and right respectively $'
msg3 db 10,13,'Press ENTER to finish $'
.code
main proc
mov ax,@data
mov ds,ax
mov cl,8
mov ch,8
;clear screen
mov ah,0
mov al,03
int 10h
print msg1
print msg2
print msg3
loop1:; wait key press:
xor ax, ax
int 16h
cmp al,0dh
je exit
cmp al,31h
je incr
cmp al,30h
je decr
cmp al,38h
je up
cmp al,32h
je down
cmp al,36h
je right
cmp al,34h
jne loop1
call getcursor
dec dl
call putcursor
jmp loop1
up: call getcursor
dec dh
call putcursor
jmp loop1
down:call getcursor
inc dh
call putcursor
jmp loop1
right:call getcursor
inc dl
call putcursor
jmp loop1
decr:cmp ch,08
je loop1
rol ch,1
call chgcursor
jmp loop1
incr:cmp ch,01
je loop1
ror ch,1
call chgcursor
jmp loop1
exit:mov ah,4ch
int 21h
main endp
chgcursor proc
;change cursor size
mov ah, 1
int 10h
ret
chgcursor endp
getcursor proc
;get cursor position and size
mov ah,03h
int 10h
ret
getcursor endp
putcursor proc
;show the cursor
mov ah,02h
int 10h
ret
putcursor endp
end
print macro msg
lea dx,msg
mov ah,09h
int 21h
endm
.model small
.stack 100h
.data
msg1 db 10,13,'Press 1 to increase and 0 to decrease the size of cursor (only 4 sizes, initially minimum) $'
msg2 db 10,13,'Press 8,2,4 and 6 to move the cursor up,down,left and right respectively $'
msg3 db 10,13,'Press ENTER to finish $'
.code
main proc
mov ax,@data
mov ds,ax
mov cl,8
mov ch,8
;clear screen
mov ah,0
mov al,03
int 10h
print msg1
print msg2
print msg3
loop1:; wait key press:
xor ax, ax
int 16h
cmp al,0dh
je exit
cmp al,31h
je incr
cmp al,30h
je decr
cmp al,38h
je up
cmp al,32h
je down
cmp al,36h
je right
cmp al,34h
jne loop1
call getcursor
dec dl
call putcursor
jmp loop1
up: call getcursor
dec dh
call putcursor
jmp loop1
down:call getcursor
inc dh
call putcursor
jmp loop1
right:call getcursor
inc dl
call putcursor
jmp loop1
decr:cmp ch,08
je loop1
rol ch,1
call chgcursor
jmp loop1
incr:cmp ch,01
je loop1
ror ch,1
call chgcursor
jmp loop1
exit:mov ah,4ch
int 21h
main endp
chgcursor proc
;change cursor size
mov ah, 1
int 10h
ret
chgcursor endp
getcursor proc
;get cursor position and size
mov ah,03h
int 10h
ret
getcursor endp
putcursor proc
;show the cursor
mov ah,02h
int 10h
ret
putcursor endp
end
No comments:
Post a Comment