您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > 汇编语言-输出1-100内素数
datasegmentPrimedb100dup(0)PrimeNumdb0PrimeSumdw0DecBufferdb5dup(0ffh);msg1db'ThePrimenumbersbelow100are:','$'msg2db'Theamountis:','$'msg3db'Thesumis:','$'dataendscodesegmentassumecs:code,ds:data;,ss:stackstart:movax,datamovds,axmovdi,offsetPrimemovbl,2loop1:cmpbl,100jznext2callPrimeTestcmpdx,0;ifbxnorprimejznext1;savetheprimenumbermovcx,0incPrimeNummov[di],blincdiincbxjmploop1next1:incbxjmploop1next2:callOutputPrimecallSumcallOutputMsg2;movah,4chint21hPrimeTestprocnear;inblcmpbx,2jzPT_next2movcl,2PT_loop1:movax,bxdivclcmpah,0jzPT_next1;notprimeincclcmpcl,bljzPT_next2;primejmpPT_loop1PT_next1:movdx,0;returnfalseretPT_next2:movdx,1;returntrueretPrimeTestendp;Sumprocnearmovcx,0movax,0movdi,offsetPrimeS_loop:movbx,0movbl,[di]addax,bxinccxincdicmpcl,PrimeNumjnzS_loopS_end:movPrimeSum,axretSumendp;OutputPrimeprocnearleadx,msg1movah,09hint21hcallPutCRLFmovdi,0movcx,0movcl,PrimeNumOP_loop:movbx,0movbl,[di]calldisp10callPutCRLFincdiloopOP_loopretOutputPrimeendp;OutputMsg2procnearcallPutCRLFleadx,msg2movah,09hint21hmovbx,0movbl,PrimeNumcalldisp10callPutCRLFleadx,msg3movah,09hint21hmovbx,PrimeSumcalldisp10callPutCRLFretOutputMsg2endp;Disp10procnear;inbxpushcxpushdileadi,DecBufferadddi,4movax,bxmovcx,10Dp_loop1:movdx,0divcxordl,30hmov[di],dldecdicmpax,0jnzDp_loop1Dp_loop2:incdimovdl,[di]movah,02hint21hcmpdi,offsetDecBuffer+4jnzDp_loop2Dp_end:popdipopcxretDisp10endp;PutCRLFprocnearmovah,02hmovdl,0ahint21hmovdl,0dhint21hretPutCRLFendpcodeendsendstart
本文标题:汇编语言-输出1-100内素数
链接地址:https://www.777doc.com/doc-5246891 .html