汇编语言-计算Fibonacci数

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

datasegmentOutputBufferdb10dup(0ffh)fibndw25rsnum1Ldw?rsnum1Hdw?rsnum2Ldw?rsnum2Hdw?rtnumLdw?rtnumHdw?msgdb'Fib(n)=','$'dataendscodesegmentassumecs:code,ds:data;,ss:stackmainprocfarstart:movax,datamovds,axmovax,fibncallFibcallSendMsgcallOutputDecmovah,02hmovdl,0ahint21hmovdl,0dhint21hmovah,4chint21hmainendpFibproc;inax,outrtnumpushaxcmpax,2janext1movrtnumL,1movrtnumH,0jmpfib_endnext1:decax;rsnum1=fib(ax-1)callFibmovdx,rtnumLpushdxmovdx,rtnumHpushdxdecax;rsnum2=fib(ax-2)callFibmovdx,rtnumLmovrsnum2L,dxmovdx,rtnumHmovrsnum2H,dx;popdxmovrsnum1H,dxpopdxmovrsnum1L,dx;rtnum=rsnum1+rsnum2movdx,rsnum1Ladddx,rsnum2LmovrtnumL,dxmovdx,rsnum1Hadcdx,rsnum2HmovrtnumH,dxfib_end:popaxretFibendp;OutputDecPROCnearleadi,offsetOutputBufferadddi,9MOVBX,10C0:MOVDX,0MOVAX,rtnumHCMPAX,0JEC1DIVBXMOVrtnumH,AXMOVAX,rtnumLDIVBXMOVrtnumL,AXORDL,30HMOV[DI],DLDECDIJMPC0C1:MOVAX,rtnumLC2:CMPAX,0JZC3MOVDX,0DIVBXORDL,30HMOV[di],DLDECDIJMPC2C3:incdimovah,02hmovdl,[di]int21hcmpdi,9jnzC3RETOutputDecENDP;SendMsgprocnearmovah,09hleadx,msgint21hretSendMsgendp;codeendsendstart

1 / 3
下载文档,编辑使用

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

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

×
保存成功