微机原理课程设计_打字练习_汇编课程设计|精品课程网站设计|课程设计网报告总结心得
运行可执行程序testword.exe,出现菜单主界面,按回车键出现由26个字母组成的乱序行,这时其中任一字母落下,在键盘上敲入该字母,如果输入正确,字母消失;按ESC键返回主界面;按空格见暂停;按‘E’退出。
Init_game macro op1,op2,op3,op4,op5,op6mov cx,00hmov dh,op1mov dl,op2op6:mov ah,02hmov bh,00hint 10hpush cxmov ah,0ahmov al,op3mov bh,00hmov cx,01hint 10hpop cxinc cxinc op4cmp cx,op5jne op6endmclear_screen macro op1,op2,op3,op4 ;清屏宏定义mov ah,06hmov al,00hmov bh,07hmov ch,op1mov cl,op2mov dh,op3mov dl,op4int 10hmov ah,02hmov bh,00hmov dh,00hmov dl,00hint 10hendmmenu macro op1,op2,op3 ;菜单显示宏定义mov ah,02hmov bh,00hmov dh,op1mov dl,op2int 10hmov ah,09hlea dx,op3int 21hendmdata segmentZK db "WELCOME TO PLAY$"no db "date:2003/6/24$"meg db "press Enter key to continue.......$"meg1 db "when a letter is dropping,please hit it!$"meg2 db "press space key to pause!$"meg3 db "press ESC key to return main interface!$"meg4 db "press letter 'E' to exit!$"speed dw 600dletters db "jwmilzoeucgpravskntxhdyqfb"db "iytpkwnxlsvxrmofzhgaebudjq"db "nwimzoexrphysfqtvdcgljukda"letters_bak db "jwmilzoeucgpravskntxhdyqfb"db "iytpkwnxlsvxrmofzhgaebudjq"db "nwimzoexrphysfqtvdcgljukda"letter_counter db 0life_flag db 78 dup(0)position_flag db 78 dup(0)present_position db 1data endsstack segment para stack 'stack'db 64 dup(0)stack endscode segmentmain proc farassume cs:code,ds:data,ss:stackstart: mov ax,datamov ds,axmov letter_counter,00hmov present_position,1lea si,position_flagmov ah,00hmov cx,00hinit_postion_flag:mov [si],ahinc siinc cxcmp cx,78djne init_postion_flaglea di,letterslea si,letters_bakmov cx,00hinit_letters:mov ah,[si]mov [di],ahinc siinc diinc cxcmp cx,78djne init_lettersmov ah,00hlea si,life_flagmov cx,00hinit_life_flag:mov [si],ahinc siinc cxcmp cx,78djne init_life_flagmov cx,00hmov ah,01hor ch,00010000bint 10hclear_screen 00d,00d,24d,79dInit_game 00d,00d,0ah,dl,80d,nextsign1Init_game 24d,00d,0ah,dl,80d,nextsign2Init_game 00d,00d,0ah,dh,25d,nextsign3Init_game 00d,79d,0ah,dh,25d,nextsign4menu 05d,15d,ZK ;菜单信息的宏调用menu 07h,15d,nomenu 09d,15d,megmenu 11d,15d,meg1menu 13d,15d,meg2menu 15d,15d,meg3menu 17d,15d,meg4put: mov ah,02h ;设置光标位置mov bh,00hmov dh,22dmov dl,33dint 10hmov ah,01h ;从键盘输入任意字符int 21hcmp al,0dhje speed3cmp al,45hje exitexit: mov ah,4chint 21hspeed3: mov ax,speed+12mov speed,axjmp beginbegin: clear_screen 01d,01d,23d,78d ;清屏宏调用clear_screen 01d,01d,23d,78dInit_game 23d,01d,01h,dl,78d,nextsign5mov ah,02hmov bh,00hmov dh,01hmov dl,01hint 10hmov cx,00hlea si,lettersnextletter:mov ah,02h ;显示字母mov dl,[si]int 21hinc siinc cxcmp cx,78dje nextcyclejmp nextletterfrom_front:sub present_position,78djmp gobackto_sifind_zero:cmp letter_counter,78dje recyclecmp present_position,78dje from_onemov ah,00hnextsi: add present_position,01hinc sicmp [si],ahje gobackto_dicmp present_position,78dje from_onejmp nextsifrom_one:mov present_position,01hjmp gobackto_sirecycle:mov letter_counter,00hmov present_position,01dlea si,position_flagmov cx,00hmov ah,00hclearsi: mov [si],ahinc cxcmp cx,78dje nextcycleinc sijmp clearsinextcycle:lea di,letterslea si,position_flagadd present_position,31dcmp present_position,78ja from_frontgobackto_si:add si,word ptr present_positiondec simov ah,[si]cmp ah,01hje find_zerogobackto_di:mov ah,01hmov [si],ahadd di,word ptr present_positiondec dimov dl,present_positionmov ah,02hmov bh,00hmov dh,01hint 10hmov cx,00hnextrow: push cxmov cx,00hout_cycle: ; 延迟push cxmov cx,00hin_cycle:add cx,01hcmp cx,1000jne in_cyclepush dxmov ah,06h ;从键盘输入字符mov dl,0ffhint 21hpop dxjz passcmp al,1bh ;如果键入ESC,则返回主菜单je to_start1cmp al," " ;如果键入SPACE,则游戏暂停je pausecmp al,[di] ;输入字母正确!则字母消失je disappearpass: pop cxinc cxcmp cx,speedje printjmp out_cyclepause: push dx ;暂停处理mov ah,06hmov dl,0ffhint 21hpop dxcmp al," "jne pausejmp passto_start1: ;返回主菜单jmp startprint:mov ah,0ah ;在当前光标位置写空格mov al," "mov bh,00hmov cx,01hint 10hinc dhmov ah,02h ;改变光标位置mov bh,00hint 10hmov ah,0ah ;在当前光标位置写字母mov al,[di]mov bh,00hmov cx,01hint 10hpop cxinc cxcmp cx,21dje print_next_letterjmp nextrow ;下一行disappear: ;击中字母后输出空格pop cxpop cxmov ah,0ahmov al," "mov bh,00hmov cx,01hint 10hjmp hitprint_next_letter:lea si,life_flagadd si,word ptr present_positiondec simov ah,0ahmov al," "mov bh,00hmov cx,01hint 10hinc dhmov ah,02hmov bh,00hint 10hmov ah,0ahmov al," "mov bh,00hmov cx,01hint 10hmov ah,1mov [si],ahhit: mov ah,02hmov bh,00hmov dh,01hmov dl,present_positionint 10hmov al,[di] ; 出现下一个新字母的数法add al,7cmp al,7ahja convey_lettermov ah,0ahmov bh,00hmov cx,01hint 10hmov [di],aladd letter_counter,01hjmp nextcycleconvey_letter:sub al,7ahadd al,61hmov ah,0ahmov bh,00hmov cx,01hint 10hmov [di],aladd letter_counter,01hjmp nextcycleclear_screen 01,01,23,78mov ah,02hmov bh,00hmov dh,11dmov dl,20dint 10hinc dhinc dhmov ah,02hmov bh,00hint 10hnotkey:mov ah,07hint 21hcmp al,0dhje to_startcmp al,1bhje overjmp notkeyto_start:clear_screen 00,00,24,79jmp startover: clear_screen 01,01,23,78mov ah,02hmov bh,00hmov dh,11dmov dl,15hint 10hmov ah,02hmov bh,00hmov dh,13dmov dl,15hint 10hmov ah,07hint 21hmov ah,07hint 21hclear_screen 00,00,24,79mov ax,4c00hint 21hmain endpcode endsend start