微机原理ch04arthimeticandlogicalinstructionsandprograms

微机原理ch04arthimeticandlogicalinstructionsandprograms

ID:30457123

大小:1.21 MB

页数:48页

时间:2018-12-30

微机原理ch04arthimeticandlogicalinstructionsandprograms_第1页
微机原理ch04arthimeticandlogicalinstructionsandprograms_第2页
微机原理ch04arthimeticandlogicalinstructionsandprograms_第3页
微机原理ch04arthimeticandlogicalinstructionsandprograms_第4页
微机原理ch04arthimeticandlogicalinstructionsandprograms_第5页
资源描述:

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

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

2、andcanbe:laregisterlinmemoryThesourceoperandcanbe:laregisterlinmemory,orlimmediateRememberthatmemory-to-memoryoperationareNEVERallowedin80x86assemblylanguage.TheinstructioncouldchangeanyoftheZF,SF,AF,CF,orPFbitoftheflagregister,dependingontheoperandsinvolved.Example:

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

4、of1siszero(zeroisanevennumber)AF=1,thereisacarryoutfromd3tod4ZF=1,theresultoftheadditioniszero(for8bits)4.1.1.1Case1:AdditionofindividualbyteandworddataExample1:Writeaprogramtocalculatethetotalof5bytesofdata.Thedecimaldataisasfollow:125,235,197,91,and48.titleprog3-1A

5、adding5bytes.modelsmall.stack64;----------------------------------.datacountequ05data1db125,235,197,91,48org0008hsumdw?;----------------------------------.codemainprocfarmovax,@datamovds,axmovcx,count;CXistheloopcountermovsi,offsetdata1;SIisthedatapointermovax,00;AXw

6、illbeholdthesumback:addal,[si];addthenextbytetoALjncover;ifnocarry,continueincah;elseaccumulatethecarryinAHover:incsi;incrementthedatapointerdeccx;decrementtheloopcounterjnzback;ifnotfinished,goaddnextbytemovsum,ax;storesummovah,4chint21h;gobacktoDOSmainendpendmain4-

7、48Codesegment4-48DatasegmentandstacksegmentExample2:Writeaprogramtocalculatethetotalsumof5wordsofdata.Thedecimaldataisasfollow:27345,28521,28533,30105,and32375titleprog3-1Badding5words.modelsmall.stack64;----------------------------------.datacountequ05data2dw27345,2

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

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

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

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