资源描述:
《西安电子科技大学微机原理上机题37题.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、编写程序实现将缓冲区BUFFER中的100个字按递增排序,并按下列格式顺序显示:数据1<原序号>数据2<原序号>数据3<原序号>················程序如下(效果图):N=100DATASSEGMENTBUFFERLABELWORDX=55519REPT100X=(X+7517)mod65535DWXENDMNUMBERLABELBYTEY=0REPT100Y=Y+1DBYENDMDECIMALDB5DUP(?)MDW1DUP(?)DATASENDSSTACKSSEGMENTDW100HD
2、UP(?)TOPLABELWORDSTACKSENDSCODESSEGMENTASSUMECS:CODES,DS:DATAS,SS:STACKSSTART:MOVAX,DATASMOVDS,AXMOVES,AXMOVAX,STACKSMOVSS,AXLEASP,TOPXORAX,AX;开始程序LEASI,BUFFERLEADI,NUMBERCALLSORTMOVCX,N;显示程序开始L1:MOVAX,[SI]MOVM,5CALLDISPAXDCALLDISPEMADDSI,2;显示数值XORAX,AX
3、MOVAL,[DI]MOVM,3CALLDISPAXDCALLDISPCRINCDI;显示序号LOOPL1MOVAH,4CHMOVAL,0INT21HSORTPROCNEARPUSHSIPUSHDIPUSHAXPUSHBXPUSHCXMOVCX,N;开始冒泡程序DECCXLP1:;外循环PUSHSIPUSHDIPUSHCXLP2:;内循环MOVAX,[SI]CMPAX,[SI+2]JBENOXCHGXCHGAX,[SI+2]MOV[SI],AXMOVBL,[DI]XCHGBL,[DI+1]MOV[DI
4、],BLNOXCHG:ADDSI,2INCDILOOPLP2POPCXPOPDIPOPSILOOPLP1;冒泡结束POPCXPOPBXPOPAXPOPDIPOPSIRETSORTENDPDISPAXDPROCNEARPUSHAXPUSHBXPUSHCXPUSHDXPUSHDILEADI,DECIMALCALLTRANS16TO10MOVCX,MMOVBX,CXDECBXLEADI,DECIMAL[BX];指向最高位MOVAH,2DISPAXD2:MOVDL,[DI]ADDDL,30HDECDIINT2
5、1HLOOPDISPAXD2POPDIPOPDXPOPCXPOPBXPOPAXRETDISPAXDENDPTRANS16TO10PROCNEARPUSHAXPUSHBXPUSHCXPUSHDXPUSHDIMOVBX,10MOVCX,MTRANS1:XORDX,DXDIVBXMOV[DI],DLINCDILOOPTRANS1POPDIPOPDXPOPCXPOPBXPOPAXRETTRANS16TO10ENDPDISPEMPROCNEARPUSHAXPUSHDXMOVAL,20HMOVAH,02MOVDL
6、,ALINT21H;显示一位字符POPDXPOPAXRETDISPEMENDPDISPCRPROCNEARPUSHAXPUSHDXMOVAL,0AHMOVAH,02MOVDL,ALINT21H;显示一位字符POPDXPOPAXRETDISPCRENDPCODESENDSENDSTART