title pgm12_3 .model small .stack 100h .code main proc ; set video mode mov ah,0 mov al,3 int 10h ;move cursor mov ah,2 xor dx,dx mov bh,0 int 10h ; get keystroke mov ah,0 int 16h while_: cmp al,1bh je end_while ; if function key cmp al,0 jne else_ ;then call do_function jmp next_key else_: mov ah,2 mov dl,al int 21h next_key: mov ah,0 int 16h jmp while_ end_while: mov ah,4ch int 21h main endp do_function proc push bx push cx push dx push ax ; mov ah,3 mov bh,0 int 10h pop ax ; retrieves scan code ;case of cmp ah,72 ; uparrow? je cursor_up cmp ah,75 ; left arrow? je cursor_left cmp ah,77 ;right arrow? je cursor_right cmp ah,80 ;down arrow? je cursor_down jmp exit cursor_up: cmp dh,0 ; row 0? je scroll_down dec dh ; no, row=row-1 jmp execute cursor_down: cmp dh,24 ; last row? je scroll_up inc dh ;no, row :=+1 jmp execute cursor_left: cmp dl,0 ; col 0? jne go_left cmp dh,0 ; row 0? je scroll_down dec dh ; row =- 1 mov dl,79 jmp execute cursor_right: cmp dl,79 ;last col? jne go_right cmp dh,24 ;last row? je scroll_up inc dh ;row=+1 mov dl,0 jmp execute go_left: dec dl jmp execute go_right: inc dl jmp execute scroll_down: mov al,1 xor cx,cx mov dh,24 mov dl,79 mov bh,7 mov ah,7 int 10h jmp exit scroll_up: mov al,1 xor cx,cx mov dx,184fh mov bh,7 mov ah,6 int 10h jmp exit execute: mov ah,2 int 10h exit: pop dx pop cx pop bx ret do_function endp end main