masm 编译贪吃蛇游戏
阅读原文时间:2023年07月09日阅读:1

code:

;TITLE GAME4TH
PAGE ,
STSEG SEGMENT
DB DUP ()
STSEG ENDS
;-----------------------------------
DTSEG SEGMENT
DATAH DB 10H,10H,10H,10H,10H,10H,10H,10H,10H
DATAL DB 20H,21H,22H,23H,24H,25H,26H,27H,28H
DTSEG ENDS
CR EQU 0DH
LF EQU 0AH
;------------------------------------
CDSEG SEGMENT
MAIN PROC FAR
ASSUME CS:CDSEG,DS:DTSEG,SS:STSEG
MOV AX,DTSEG
MOV DS,AX
MOV AX,0600H
MOV BH,00011110B
MOV CX,
MOV DH,18H
MOV DL,04FH
INT 10H

FISH: MOV AX,0600H
MOV BH,00011110B
MOV CX,
MOV DH,18H
MOV DL,04FH
INT 10H
MOV AH,
MOV BH,
MOV SI,OFFSET DATAH
MOV DI,OFFSET DATAL
MOV DH,[SI]
MOV DL,[DI]
INT 10H
MOV AX,0201H
MOV DL,'+'
INT 21H
MOV AH,
MOV BH,
MOV DH,[SI]+
MOV DL,[DI]+
INT 10H
MOV AX,0201H
MOV DL,'#'
INT 21H
MOV AH,
MOV BH,
MOV DH,[SI]+
MOV DL,[DI]+
INT 10H
MOV AX,0201H
MOV DL,'#'
INT 21H
MOV AH,
MOV BH,
MOV DH,[SI]+
MOV DL,[DI]+
INT 10H
MOV AX,0201H
MOV DL,'#'
INT 21H
MOV AH,
MOV BH,
MOV DH,[SI]+
MOV DL,[DI]+
INT 10H
MOV AX,0201H
MOV DL,'#'
INT 21H
MOV AH,
MOV BH,
MOV DH,[SI]+
MOV DL,[DI]+
INT 10H
MOV AX,0201H
MOV DL,'#'
INT 21H
MOV AH,
MOV BH,
MOV DH,[SI]+
MOV DL,[DI]+
INT 10H
MOV AX,0201H
MOV DL,'#'
INT 21H
MOV AH,
MOV BH,
MOV DH,[SI]+
MOV DL,[DI]+
INT 10H
MOV AX,0201H
MOV DL,'#'
INT 21H
MOV AH,
MOV BH,
MOV DH,[SI]+
MOV DL,[DI]+
INT 10H
MOV AX,0201H
MOV DL,'>'
INT 21H

LOOP1:MOV AH, ;循环输入
MOV AL,
INT 16H
CMP AH,
JE UP
CMP AH,
JE DOWN
CMP AH,
JE RIGHT
CMP AH,
JE LEFT

UP: MOV SI,OFFSET DATAH
MOV DI,OFFSET DATAL
MOV DH,[SI]+
MOV DL,[DI]+
MOV CH,DH
MOV CL,DL
DEC DH
MOV [SI]+,DH
MOV [DI]+,DL
JMP BACK

DOWN: MOV SI,OFFSET DATAH
MOV DI,OFFSET DATAL
MOV DH,[SI]+
MOV DL,[DI]+
MOV CH,DH
MOV CL,DL
INC DH
MOV [SI]+,DH
MOV [DI]+,DL
JMP BACK

LEFT: MOV SI,OFFSET DATAH
MOV DI,OFFSET DATAL
MOV DH,[SI]+
MOV DL,[DI]+
MOV CH,DH
MOV CL,DL
DEC DL
MOV [SI]+,DH
MOV [DI]+,DL
JMP BACK

RIGHT:MOV SI,OFFSET DATAH
MOV DI,OFFSET DATAL
MOV DH,[SI]+
MOV DL,[DI]+
MOV CH,DH
MOV CL,DL
INC DL
MOV [SI]+,DH
MOV [DI]+,DL
JMP BACK

BACK: MOV DH,[SI]+
MOV DL,[DI]+
MOV [SI]+,CH
MOV [DI]+,CL
MOV CH,DH
MOV CL,DL
MOV DH,[SI]+
MOV DL,[DI]+
MOV [SI]+,CH
MOV [DI]+,CL
MOV CH,DH
MOV CL,DL
MOV DH,[SI]+
MOV DL,[DI]+
MOV [SI]+,CH
MOV [DI]+,CL
MOV CH,DH
MOV CL,DL
MOV DH,[SI]+
MOV DL,[DI]+
MOV [SI]+,CH
MOV [DI]+,CL
MOV CH,DH
MOV CL,DL
MOV DH,[SI]+
MOV DL,[DI]+
MOV [SI]+,CH
MOV [DI]+,CL
MOV CH,DH
MOV CL,DL
MOV DH,[SI]+
MOV DL,[DI]+
MOV [SI]+,CH
MOV [DI]+,CL
MOV CH,DH
MOV CL,DL
MOV DH,[SI]+
MOV DL,[DI]+
MOV [SI]+,CH
MOV [DI]+,CL
MOV CH,DH
MOV CL,DL
MOV DH,[SI]
MOV DL,[DI]
MOV [SI],CH
MOV [DI],CL
MOV CH,DH
MOV CL,DL
JMP FISH

MAIN ENDP
CDSEG ENDS
END MAIN