汇编语言-输出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 / 4
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功