文档详情

汇编语言写的贪吃蛇小游戏源代码.doc

发布:2017-01-05约字共20页下载文档
文本预览下载声明
DATA SEGMENT dw 0,0 snk db 1 blk db 32 food db 3 tal1 db 4 tal2 db 2 adrs db 5 len db ? pst db ? addrs dw ? frow db ? fcol db ? hwrt db ? gmov db game over press r to restart press q to quit $ score1 db score :$ score2 db ? score0 db 1 zero db 48 writer db Developer: Geniusdot $ email db e-mail: geniusdot@$ msg1 db The way to play the game:$ way db press w to up ,press s to down,press a to left,press d to right$ msg db Press any key(except a,s,d,w) to start$ DATA ENDS STACK SEGMENT stack db 200 dup(0) STACK ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA,SS:STACK start: mov ax,data mov ds,ax mov ax,0 mov es,ax mov frow,10 mov fcol,6 mov dh,10 mov dl,26 mov ah,2 mov bh,0 int 10h mov ah,9 lea dx,msg1 int 21h mov dh,11 mov dl,7 mov ah,2 mov bh,0 int 10h mov ah,9 lea dx,way int 21h mov dh,12 mov dl,20 mov ah,2 mov bh,0 int 10h mov ah,9 lea dx,msg int 21h mov ah,0 int 16h mov ah,6 mov al,0 mov ch,0 mov cl,0 mov dh,24 mov dl,79 mov bh,10 int 10h mov dh,0 mov dl,0 mov ah,2 mov bh,0 int 10h mov ah,9 lea dx,score1 int 21h mov dl,15 mov ah,2 mov bh,0 int 10h mov ah,9 lea dx,writer int 21h mov ah,9 lea dx,email int 21h mov score2,48 push es:[9*4] ;将原int9入口地址保存 pop ds:[0] push es:[9*4+2] pop ds:[2] mov word ptr es:[9*4],offset int9 ;更改中断向量表 mov es:[9*4+2],cs jmp aa write macro row,col,cnt ;宏定义用于向当前光标处输出字符 push bx push cx push dx mov dh,row mov dl,col mov ah,2 mov bh,0 int 10h mov ah,9 mov bl,11 mov cx,1 lea di,cnt ;50 mov al,[di] int 10h pop dx pop cx pop bx endm readh macro row,col ;宏定义用于读出当前光标处字符 push dx push ax push bx mov dh,row mov dl,col mov ah,2 mov bh,0 int 10h mov ah,08h int 10h mov pst,al pop bx pop ax pop dx endm wnear macro ;宏定义只用在readcg宏中当readcg的所有判断都不成立调用此宏 local wnext1 local wnext2 local wnext3 local wnext
显示全部
相似文档