当前位置:文档之家› 汇编语言小程序记录鼠标路径

汇编语言小程序记录鼠标路径

汇编语言小程序记录鼠标路径
汇编语言小程序记录鼠标路径

;TITLE DRAW--Program to draw on screen with

;cursor arrows,character write to video memory

;------------------------------------------------------------------------

read_c equ0h;read character word

key_rom equ16h;rom keyboard routine

up equ48h;scan code for up arrow

down equ50h;scan code for down arrow

right equ4dh;scan code for right arrow

left equ4bh;scan code for left arrow

block equ01h;solid graphics character

quit equ1bh;escape key

;************************************************************************* video segment at0b800h;define extra seg

wd_buff label w ord

v_buff db25*80*2 dup (?)

video ends

;************************************************************************* pro_nam segment;define code segment

;------------------------------------------------------------------------

main proc far;main part of program

assume cs:pro_nam,es:video

;set up stack for return

start:push d s;save ds

sub ax,ax;set ax to zero

push a x;put it on stack

;set es to extra segment

mov ax,video

mov es,ax

;clear screen by writing zeros to it

;even bytes get 0(characters)

;odd bytes get 7(normal"attribute")

mov cx,80*25

mov bx,0

clear:mov es:[wd_buff+bx],0700h

inc bx;increase pointer

inc bx;twice

loop clear;do again

;screen pointer will be in cx register

;row nuber(0 to 24 d)in ch

;column nuber(0 to 79d)in cl

;set screen pointer to center of screen

mov ch,12d;row divide by 2

mov cl,40d;column divide by2

;get character from keyboard,using rom bios routine

get_char:

mov ah,read_c;code for read char

int key_rom;keyboard i/o rom call

cmp al,quit;is it escape?

jz exit;yes

mov al,ah;put scan code in al

cmp al,up;is it up arrow?

jnz not_up;no

dec ch;yes,decrement row

not_up:

cmp al,down;is it down arrow?

jnz not_down;no

inc ch;yes,increase row

not_down:

cmp al,right;is it right arrow?

jnz not_right;no

inc cl;yes,increase column

not_right:

cmp al,left;is it left arrow?

jnz lite_it;no

dec cl;yes,decrement column

lite_it:

mov al,160d;bytes per row into al

mul ch;time of rows

;result in ax

mov bl,cl;of columns in bl

rol bl,1;times 2 to get bytes

mov bh,0;clear top part of bx

add bx,ax;add ax to it

;gives address offset

;address offset in bx. put block char there

mov al,block

mov es:[v_buff+bx],al

jmp get_char;get next arrow

exit:ret;return to dos

main endp;end of main part of program

;-----------------------------------------------------------------------

pro_nam ends;end of code segment

;*********************************************************************** end start;end assembly

相关主题
文本预览
相关文档 最新文档