微机原理ch04 arthimetic and logical instructions and programs

微机原理ch04 arthimetic and logical instructions and programs

ID:33175985

大小:1.18 MB

页数:48页

时间:2019-02-21

微机原理ch04 arthimetic and logical instructions and programs_第1页
微机原理ch04 arthimetic and logical instructions and programs_第2页
微机原理ch04 arthimetic and logical instructions and programs_第3页
微机原理ch04 arthimetic and logical instructions and programs_第4页
微机原理ch04 arthimetic and logical instructions and programs_第5页
资源描述:

《微机原理ch04 arthimetic and logical instructions and programs》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库

1、4ARTHIMETICANDLOGICALINSTRUCTIONSANDPROGRAMS4.1USINGADDITIONANDSUBTRATION4.1.1AdditionofunsignednumbersTheformoftheADD/ADCinstructionis:adddest,source;dest=dest+sourceadcdest,source;dest=dest+source+CFTheinstructionsADDandADCareusedtoaddtwooperands.Thedestinat

2、ionoperandcanbe:laregisterlinmemoryThesourceoperandcanbe:laregisterlinmemory,orlimmediateRememberthatmemory-to-memoryoperationareNEVERallowedin80x86assemblylanguage.TheinstructioncouldchangeanyoftheZF,SF,AF,CF,orPFbitoftheflagregister,dependingontheoperandsinv

3、olved.Example:Showhowtheflagregisterisaffectedby:moval,0f5haddal,0bhSolution:F511110101+0B00001011---------------100000000004-48Aftertheaddition,theALregister(destination)contains00Handtheflagsareasfollows:CF=1,sincethereisacarryoutfromd7SF=0,thestatusofd7ofth

4、eresultPF=1,thenumberof1siszero(zeroisanevennumber)AF=1,thereisacarryoutfromd3tod4ZF=1,theresultoftheadditioniszero(for8bits)4.1.1.1Case1:AdditionofindividualbyteandworddataExample1:Writeaprogramtocalculatethetotalof5bytesofdata.Thedecimaldataisasfollow:125,23

5、5,197,91,and48.titleprog3-1Aadding5bytes.modelsmall.stack64;----------------------------------.datacountequ05data1db125,235,197,91,48org0008hsumdw?;----------------------------------.codemainprocfarmovax,@datamovds,axmovcx,count;CXistheloopcountermovsi,offsetd

6、ata1;SIisthedatapointermovax,00;AXwillbeholdthesumback:addal,[si];addthenextbytetoALjncover;ifnocarry,continueincah;elseaccumulatethecarryinAHover:incsi;incrementthedatapointerdeccx;decrementtheloopcounterjnzback;ifnotfinished,goaddnextbytemovsum,ax;storesummo

7、vah,4chint21h;gobacktoDOSmainendpendmain4-48Codesegment4-48DatasegmentandstacksegmentExample2:Writeaprogramtocalculatethetotalsumof5wordsofdata.Thedecimaldataisasfollow:27345,28521,28533,30105,and32375titleprog3-1Badding5words.modelsmall.stack64;--------------

8、--------------------.datacountequ05data2dw27345,28521,28533,30105,32375org0010hsumdw2dup(?);----------------------------------.codemainprocfarmovax,@datamovds,axclc;clearcarrybefor

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。