【正文】
DATA SEGMENTdw 0,0snk db 1blk db 32food db 3tal1 db 4tal2 db 2adrs db 5len db ?pst db ?addrs dw ?frow db ?fcol db ?hwrt db ?gmov db 39。game over press r to restart press q to quit $39。score1 db 39。score :$39。score2 db ?score0 db 1zero db 48writer db 39。Developer: Geniusdot $39。 db 39。 geniusdot@$39。msg1 db 39。The way to play the game:$39。way db 39。 press w to up ,press s to down,press a to left,press d to right$39。msg db 39。Press any key(except a,s,d,w) to start$39。DATA ENDSSTACK SEGMENT stack db 200 dup(0)STACK ENDSCODE SEGMENTASSUME CS:CODE,DS:DATA,SS:STACKstart:mov ax,datamov ds,axmov ax,0mov es,axmov frow,10mov fcol,6mov dh,10 mov dl,26mov ah,2mov bh,0int 10hmov ah,9lea dx,msg1int 21hmov dh,11mov dl,7mov ah,2mov bh,0int 10hmov ah,9lea dx,wayint 21hmov dh,12mov dl,20mov ah,2mov bh,0int 10hmov ah,9lea dx,msgint 21hmov ah,0int 16hmov ah,6mov al,0mov ch,0mov cl,0mov dh,24mov dl,79mov bh,10int 10hmov dh,0mov dl,0mov ah,2mov bh,0int 10hmov ah,9lea dx,score1int 21hmov dl,15mov ah,2mov bh,0int 10hmov ah,9lea dx,writerint 21hmov ah,9lea dx,int 21hmov score2,48push 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],csjmp aawrite macro row,col,t 。宏定義用于向當前光標處輸出字符 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,t 。50 mov al,[di] int 10h pop dx pop cx pop bxendmreadh macro row,col 。宏定義用于讀出當前光標處字符 push dxpush axpush bxmov dh,rowmov dl,colmov ah,2mov bh,0int 10hmov ah,08hint 10hmov pst,alpop bxpop axpop dxendmwnear macro 。宏定義只用在readcg宏中當readcg的所有判斷都不成立調(diào)用此宏local wnext1local wnext2