您好,欢迎访问三七文档
本人对80x86汇编编程的一些了解,在这里和大家分享。(1)显示“生日快乐”程序:DATASSEGMENTdb12345678901234567890123456789012345678901234567890123456789012345;此处输入数据段代码db*********************db****************db*******************db***********************************db*****************db************db********************************DATASENDSSTACKSSEGMENTdw20hdup(0);此处输入堆栈段代码STACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXMOVAX,STACKSMOVSS,AXmovsp,20hmovax,0b800hmoves,axmovsi,65movbx,0movdx,7s:movdi,0movcx,60s0:moval,[si]moves:[di+bx+160*9+20],alincsiadddi,2loops0addsi,5addbx,160decdxcmpdx,0jnesmovdx,12movbx,0s1:movdi,0movcx,20s2:moval,07hmoves:[di+bx+1],almoval,16hmoves:[di+bx+41],almoval,25hmoves:[di+bx+81],almoval,34hmoves:[di+bx+121],aladddi,2deccxcmpcx,0jnes2addbx,160decdxcmpdx,0jnes1movdx,12movbx,160*13s3:movdi,0movcx,20s4:moval,43hmoves:[di+bx+1],almoval,52hmoves:[di+bx+41],almoval,61hmoves:[di+bx+81],almoval,70hmoves:[di+bx+121],aladddi,2deccxcmpcx,0jnes4addbx,160decdxcmpdx,0jnes3movcx,65534s8:movbx,100000s7:decbxcmpbx,0jnes7loops8movcx,4000movdi,1moval,0movah,0int16hcmpal,'r'jes5jmps6s5:moval,4ahmoves:[di],aladddi,2loops5jmps9s6:moval,0a4hmoves:[di],aladddi,2loops6s9:jmps8;此处输入代码段代码MOVAH,4CHINT21HCODESENDSENDSTART(2)实时时钟程序:DATASSEGMENTdbSundaydbMondaydbTuesdaydbWednesdaydbThursdaydbFirdaydbSaturday;此处输入数据段代码DATASENDSCODESSEGMENTASSUMECS:CODESSTART:MOVAX,0B800HMOVDS,AXMOVSI,0MOVDL,9MOVCH,3S1:MOVAL,DL;提取和显示年、月、日OUT70H,ALNOPNOPINAL,71HMOVAH,0MOVDH,ALMOVCL,4SHLAX,CLMOVAL,DHADDAL,0AAAADDAH,30HADDAL,30HMOV[SI+160*12+31*2],AHMOV[SI+2+160*12+31*2],ALDECCHCMPCH,0JES2MOVAL,'/'MOV[SI+4+160*12+31*2],ALADDSI,6DECDLJMPS1S2:ADDSI,6MOVDL,4MOVCH,3S3:MOVAL,DL;提取和显示时、分、秒OUT70H,ALNOPNOPINAL,71HMOVAH,0MOVDH,ALMOVCL,4SHLAX,CLMOVAL,DHADDAL,0AAAADDAH,30HADDAL,30HMOV[SI+160*12+31*2],AHMOV[SI+2+160*12+31*2],ALDECCHCMPCH,0JES4MOVAL,':'MOV[SI+4+160*12+31*2],ALADDSI,6DECDLDECDLJMPS3S4:MOVAL,6;提取和显示星期OUT70H,ALNOPNOPINAL,71HMOVBL,ALMOVAX,DATASMOVES,AXMOVDI,0MOVSI,0MOVAL,BLDECALMOVAH,0MOVBH,10MULBHADDDI,AXMOVCX,10S5:MOVAL,ES:[DI]MOVDS:[SI+160*11+34*2],ALINCDIINCSIINCSIDECCXCMPCX,0JNES5MOVCX,4000MOVSI,1S6:MOVAL,0CAH;设置背景和字体颜色MOVDS:[SI],ALINCSIINCSIDECCXCMPCX,0JNES6JMPSTARTMOVAH,4CHINT21HCODESENDSENDSTART(3)我自己写的一个小游戏程序:(大家可以将“分数”子程序的调用位置换一下,显示时就会实时更新)DATASSEGMENT;12345678901234567890;此处输入数据段代码db*db***********db***db***********db*db*db**db*****db**db**db**db***db***db**db**db**db*****db**db*db*db***********db***db***********db*;1234567890123456789012345678901234567890sm1dbup:wdown:sleft:aright:dsm2dbstart:kexit:treplay:paadb0adb134234113241423312324123142342143124423132423422314132412134231bdb142332314214132412342122342234114234234214213242312234412313434fdb0001020304050607080910111213141516171819202122232425262728293031323334353637383940db41424344454647484950515253545556575859606162636465666768697071727374757677787980db818283848586878889909192939495969979899edbscore:DATASENDSSTACKSSEGMENTdw30hdup(0);此处输入堆栈段代码STACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXmovax,0b800hmoves,axmovax,stacksmovss,axmovsp,30hcallinitcalllistmovah,0int16hpa0:cmpal,'t'jetuipa1:cmpal,'k'jnepa0moval,0movaa[0],almovbp,0callinitcallrightcallupcalldowncallleftcallbackgroundcallfencalldelaycalldelaymovsi,0movcx,99g0:moval,a[si]incsicmpal,'1'jneg2callright1callfenjmpgg2:cmpal,'2'jneg3callup1callfenjmpgg3:cmpal,'3'jneg4calldown1callfenjmpgg4:callleft1callfenjmpgg:loopg0callfenjmp$tui:MOVAH,4CHINT21Hright:pushaxpushbxpushcxpushdxpushsipushdimovsi,0movbx,0movdx,5;行号s0:movdi,0movcx,15;列号s1:moval,[si]moves:[di+bx+160+4],alincsiadddi,2loops1addbx,160decdxcmpdx,0jnes0popdipopsipopdxpopcxpopbxpopaxretright1:pushaxpushbxpushcxpushdxpushsipushdimovdl,24movbx,24*160r:movdh,5;行号movsi,0r0:movdi,0movcx,15;列号r1:moval,[si]moves:[di+bx+4],almoval,''moves:[di+bx+160+4],alincsiadddi,2loopr1addbx,160decdhcmpdh,0jner0calldelaycmpbp,0jar4movah,1int16hnopnopjzr3movah,0int16hnopnopcmpal,'t'jetuicmpal,'p'jestartcmpal,'d'jner3calltureRculorcalldelaycallbackgroundmoval,aa[0]incalmovaa[0],alincbpjmpr4r3:r4:subbx,6*160decdlcmpdl,0jnercallmeetRculorcalldelaycallbackgroundpopdipopsipopdxpopcxpopbxpopaxmovbp,0retup:pushaxpushbxpushcxpushdxpushsipushdimovsi,5*15movbx,0movdx,7;行号s2:movdi,0movcx,8;列号s3:moval,[si]moves:[di+bx+52],alincsiadddi,2loops3addbx,160decdxcmpdx,0jnes2popdipopsipopdxpopcxpopbxpopaxretup1:pushaxpushbxpushcxpushdxpushsipushdimovdl,25movbx,24*160u:movdh,7;行号movsi,75u0:movdi,0movcx,8;列号u1:moval,[si]moves:[di+bx+52],almoval,''moves:[di+bx+160+52],alincsiadddi,2loopu1addbx,160decdhcmpdh,0jneu0calldelaycmpbp,0jau4movah,1int16hnopnopjzu3movah,0int16hnopnopcmpal,'t'jetuicmpal,'p'jestartcmpal,'w'jneu3calltureUculorcalldelaycallbackgroundmoval,aa[0]incalmovaa[0],alincbpjmpu4u3:u4:subbx,8*160decdlcmpdl,0jneucallmeetUculorcalldelaycallbackgroundpopdipopsipopdxpopcxpopbxpopaxmovbp,0retdown:pushaxpushbxpushcxpushdxpushsipushdimovsi,7*8+75movbx,0movdx,7;行号s4:movdi,0movcx,8;列号s5:moval,[si]moves:[di+bx+92],alincsiadddi,2loops5addbx,160decdxcmpdx,0jnes4popdipopsipopd
本文标题:80x86汇编实例
链接地址:https://www.777doc.com/doc-3252750 .html