資源描述:
《匯編語言寫的貪吃蛇小游戲源代碼》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、DATASEGMENTdw0,0snkdb1blkdb32fooddb3tal1db4tal2db2adrsdb5lendb?pstdb?addrsdw?frowdb?fcoldb?hwrtdb?gmovdb'gameoverpressrtorestartpressqtoquit$'score1db'score:$'score2db?score0db1zerodb48writerdb'Developer:Geniusdot$'emaildb'e-mail:geniusdot@gmail.com$'msg1db'Th
2、ewaytoplaythegame:$'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,10movfco
3、l,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
4、,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],csjmpaawritemacr
5、orow,col,cnt;宏定義用于向當(dāng)前光標(biāo)處輸出字符pushbxpushcxpushdxmovdh,rowmovdl,colmovah,2movbh,0int10hmovah,9movbl,11movcx,1leadi,cnt;50moval,[di]int10hpopdxpopcxpopbxendmreadhmacrorow,col;宏定義用于讀出當(dāng)前光標(biāo)處字符pushdxpushaxpushbxmovdh,rowmovdl,colmovah,2movbh,0int10hmovah,08hint10hmovp
6、st,alpopbxpopaxpopdxendmwnearmacro;宏定義只用在readcg宏中當(dāng)readcg的所有判斷都不成立調(diào)用此宏localwnext1localwnext2localwnext3localwnext4pushdxdecdhreadhdh,dlcmppst,1jnewnext1writedh,dl,tal2jmpwnext4wnext1:incdhdecdlreadhdh,dlcmppst,1jnewnext2writedh,dl,tal2jmpwnext4wnext2:incdhincdl
7、readhdh,dlcmppst,1jnewnext3writedh,dl,tal2jmpwnext4wnext3:decdhincdlreadhdh,dlcmppst,1jnewnext4writedh,dl,tal2wnext4:popdxendmreadcgmacrorow,col;宏定義用于改變判斷出來的字符localtnup,tnup1,tnup2,tnlf,tnlf1,tnlf2,tndn,tndn1,tndn2,tnrt,tnrt1,tnrt2,gooutpushbxpushaxpushdxwrite
8、dh,dl,tal1decrowreadhdh,dlcmppst,4jnetnup1jmptnup2tnup1:jmpnearptrtnuptnup2:writedh,dl,blkincdhincdhreadhdh,dlcmppst,1jnetnupwritedh,dl,tal2jmpnearptrgoouttnup:popdxpushdxdeccolrea