您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > 汇编语言写的贪吃蛇小游戏源代码
DATASEGMENTdw0,0snkdb1blkdb32fooddb3tal1db4tal2db2adrsdb5lendb?pstdb?addrsdw?frowdb?fcoldb?hwrtdb?gmovdb'gameoverpressrtorestartpressqtoquit$'score1db'score:$'score2db?score0db1zerodb48writerdb'Developer:Geniusdot$'emaildb'e-mail:geniusdot@gmail.com$'msg1db'Thewaytoplaythegame:$'waydb'presswtoup,pressstodown,pressatoleft,pressdtoright$'msgdb'Pressanykey(excepta,s,d,w)tostart$'DATAENDSSTACKSEGMENTstackdb200dup(0)STACKENDSCODESEGMENTASSUMECS:CODE,DS:DATA,SS:STACKstart:movax,datamovds,axmovax,0moves,axmovfrow,10movfcol,6movdh,10movdl,26movah,2movbh,0int10hmovah,9leadx,msg1int21hmovdh,11movdl,7movah,2movbh,0int10hmovah,9leadx,wayint21hmovdh,12movdl,20movah,2movbh,0int10hmovah,9leadx,msgint21hmovah,0int16hmovah,6moval,0movch,0movcl,0movdh,24movdl,79movbh,10int10hmovdh,0movdl,0movah,2movbh,0int10hmovah,9leadx,score1int21hmovdl,15movah,2movbh,0int10hmovah,9leadx,writerint21hmovah,9leadx,emailint21hmovscore2,48pushes:[9*4];将原int9入口地址保存popds:[0]pushes:[9*4+2]popds:[2]movwordptres:[9*4],offsetint9;更改中断向量表moves:[9*4+2],csjmpaawritemacrorow,col,cnt;宏定义用于向当前光标处输出字符pushbxpushcxpushdxmovdh,rowmovdl,colmovah,2movbh,0int10hmovah,9movbl,11movcx,1leadi,cnt;50moval,[di]int10hpopdxpopcxpopbxendmreadhmacrorow,col;宏定义用于读出当前光标处字符pushdxpushaxpushbxmovdh,rowmovdl,colmovah,2movbh,0int10hmovah,08hint10hmovpst,alpopbxpopaxpopdxendmwnearmacro;宏定义只用在readcg宏中当readcg的所有判断都不成立调用此宏localwnext1localwnext2localwnext3localwnext4pushdxdecdhreadhdh,dlcmppst,1jnewnext1writedh,dl,tal2jmpwnext4wnext1:incdhdecdlreadhdh,dlcmppst,1jnewnext2writedh,dl,tal2jmpwnext4wnext2:incdhincdlreadhdh,dlcmppst,1jnewnext3writedh,dl,tal2jmpwnext4wnext3:decdhincdlreadhdh,dlcmppst,1jnewnext4writedh,dl,tal2wnext4:popdxendmreadcgmacrorow,col;宏定义用于改变判断出来的字符localtnup,tnup1,tnup2,tnlf,tnlf1,tnlf2,tndn,tndn1,tndn2,tnrt,tnrt1,tnrt2,gooutpushbxpushaxpushdxwritedh,dl,tal1decrowreadhdh,dlcmppst,4jnetnup1jmptnup2tnup1:jmpnearptrtnuptnup2:writedh,dl,blkincdhincdhreadhdh,dlcmppst,1jnetnupwritedh,dl,tal2jmpnearptrgoouttnup:popdxpushdxdeccolreadhdh,dlcmppst,4jnetnlf1jmptnlf2tnlf1:jmpnearptrtnlftnlf2:writedh,dl,blkincdlincdlreadhdh,dlcmppst,1jnetnlfwritedh,dl,tal2jmpnearptrgoouttnlf:popdxpushdxincrowreadhdh,dlcmppst,4jnetndn1jmptndn2tndn1:jmpnearptrtndntndn2:writedh,dl,blkdecdhdecdhreadhdh,dlcmppst,1jnetndnwritedh,dl,tal2jmpnearptrgoouttndn:popdxpushdxinccolreadhdh,dlcmppst,4jnetnrt1jmptnrt2tnrt1:jmpnearptrtnrttnrt2:writedh,dl,blkdecdldecdlreadhdh,dlcmppst,1jnetnrtwritedh,dl,tal2jmpnearptrgoouttnrt:popdxpushdxwneargoout:popdxpopaxpopbxendmaddone:;此标号功能是将蛇身增加一pushdxincscore2movdh,1movdl,0movcx,23cmpad1:pushcxmovcx,79cmpad2:readhdh,dlcmppst,2jnenextad3jmpnextad4nextad3:jmpnearptrnextadnextad4:writedh,dl,snkdecdhreadhdh,dlcmppst,4jnenatupwritedh,dl,tal2decdhwritedh,dl,tal1jmpoutonatup:incdhdecdlreadhdh,dlcmppst,4jnenatlfwritedh,dl,tal2decdlwritedh,dl,tal1jmpoutonatlf:incdhincdlreadhdh,dlcmppst,4jnenatdnwritedh,dl,tal2incdhwritedh,dl,tal1jmpoutonatdn:decdhincdlreadhdh,dlcmppst,4jnenatrtwritedh,dl,tal2incdlwritedh,dl,tal1natrt:outo:popcxjmpnearptrendadnextad:incdljmpnextad2chgad2:jmpnearptrcmpad2nextad2:loopchgad2subdl,79incdhpopcxjmpnextad1chgad1:jmpnearptrcmpad1nextad1:loopchgad1endad:popdxjmpnearptrcrtfaa:;从这开始产生最原始的蛇movaddrs,offsetturnrightmovdh,10movdl,1movcx,3writedh,dl,tal1incdlwritedh,dl,tal2wrt:incdlwritedh,dl,snkloopwrtmovlen,6movax,0jmpwrt1ovflw:;当蛇碰壁或自身转到此游戏结束movah,6moval,0movch,0movcl,0movdh,24movdl,79movbh,7int10hmovdh,17movdl,17movah,2movbh,0int10hmovah,9leadx,gmovint21hmovax,0;恢复int9中断moves,axpushds:[0]popes:[9*4]pushds:[2]popes:[9*4+2]stop:movah,0int16hcmpal,'r'jeaa1jmpaa2aa1:jmpnearptrstartaa2:cmpal,'q'jnestopjmpnearptrexitwrt1:;此处蛇行走过程的无限循环calldlypushdxincdhcmpdh,25jeovflwincdlcmpdl,80jeovflwpopdxpushdxdecdhcmpdh,0jeovflwdecdlcmpdl,-1jeovflwpopdxpushdxleaax,turnrightcmpaddrs,axjnetonxt2incdlreadhdh,dlcmppst,1jetonxt1cmppst,2jetonxt1cmppst,4jetonxt1jmptonxt2tonxt1:jmpovflwtonxt2:popdxpushdxleaax,turnupcmpaddrs,axjnetonxt4decdhreadhdh,dlcmppst,1jetonxt3cmppst,2jetonxt3cmppst,4jetonxt3jmptonxt4tonxt3:jmpovflwtonxt4:popdxpushdxleaax,turndowncmpaddrs,axjnetonxt6incdhreadhdh,dlcmppst,1jetonxt5cmppst,2jetonxt5cmppst,4jetonxt5jmptonxt6tonxt5:jmpovflwtonxt6:popdxpushdxleaax,turnbackcmpaddrs,axjnetonxt8decdlreadhdh,dlcmppst,1jetonxt7cmppst,2jetonxt7cmppst,4jetonxt7jmptonxt8tonxt7:jmpovflwtonxt8:popdxjmpnextacrtf1:jmpnearptraddonecrtf:callrand1callrand2incfrowmovah,frowmoval,fcolpushdxmovdh,1movdl,0pushcxmovcx,23check1:pushcxmovcx,79check2:readhdh,dlcmppst,1jenextncmppst,2jenextncmppst,4jenextnjmpnextnnnextn:cmpax,dxjecrtfnextnn:incdlloopcheck2incdhsubdl,79popcxloopcheck1popcxpopdxwritefrow,fcol,foodnexta:movah,frowmoval,fcolcmpax,dxjecrtf12jmpcrtf13crtf12:jmpnearptrcrtf1crtf13:pushdxcmpscore2,58jlnormalmovscore2,49incscore0normal:movdh,0movdl,8writedh,dl,score2adddl,score0writedh,dl,zeropopdxcmpadrs,17jejmp1cmpadrs,145jejmp1cmpadrs,31jejmp2cmpadrs,159jejmp2cmpadrs,32jejmp3cmpadrs,160jejmp3cmpadrs,30jejmp4cmpadrs,158jejmp4jmpaddrsjmp1:leaax,turndowncmpax,addrsjejmp2movaddrs,offsettur
本文标题:汇编语言写的贪吃蛇小游戏源代码
链接地址:https://www.777doc.com/doc-4094431 .html