版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
Chapter8BitManipulationContents:LogicalOperationsShiftandRotateInstructions8.1LogicalOperationsANDdestination,sourceTESTdestination,sourceThesameasANDinstructionbutnotchangedestinationNOTdestinationORdestination,sourceinclusiveXORdestination,sourceexclusiveTruetableABT000010100111ANDsrcregmemimmreg√√√mem√√destABT000011101110ABT000011101111AT0110flagsLogicaloperationexceptforNOTwillaffectflagregister.CF=0OF=0AF:undefinedPF,SF,ZF:setbythevalueofresult.Clearselectedbits(marking)ClearallbutthelastfourbitsinEAXANDeax,0000000fhSetselectedbitsSetallbutthelastfourbitsinEAXOReax,fffffff0hnegateselectedbitsnegateallbutthelastfourbitsinEAXXOReax,fffffff0hXoreax,eax;AND指令可用于復(fù)位某些位(同0相與),不影響其他位:將BL中D3和D0位清0,其他位不變and
bl,11110110B;OR指令可用于置位某些位(同1相或),不影響其他位:將BL中D3和D0位置1,其他位不變or
bl,00001001B;XOR指令可用于求反某些位(同1相異或),不影響其他位:將BL中D3和D0位求反,其他不變xor
bl,00001001BPerformcertainarithmeticoperationmovedx,0movebx,32divebxmovedx,eaxandedx,0000001fhManipulateASCIIcodesConvertASCIIcodetointegerSubeax,00000030hAndeax,0000000fhConvertintegertoASCIIOrbl,30hChangethecaseofASCIIcodeXorcl,00100000bApplicationofTESTExamineaparticularbitis“1”or“0”Testdx,2023hGetinformationaboutavalueTestcx,cxThefollowinginstructionusuallyis“jcc”testal,01h
;測試AL旳最低位D0jnzthere ;標(biāo)志ZF=0,即D0=1 ;則程序轉(zhuǎn)移到there... ;不然ZF=1,即D0=0,順序執(zhí)行there:...
TEST指令一般用于檢測某些條件是否滿足,但又不希望變化原操作數(shù)旳情況TESTShiftandRotateShiftandrotateinstructionsmanipulatebinarynumbersatthebinarybitlevel,asdidtheAND,OR,Exclusive-OR,andNOTinstructions.Shiftsandrotatesfindtheirmostcommonapplicationsinlow-levelsoftwareusedtocontrolI/Odevices.Themicroprocessorcontainsacompletesetofshiftandrotateinstructionsthatareusedtoshiftorrotateanymemorydataorregister.ShiftinstructionsShiftinstructionspositionormovenumberstotheleftorrightwithinaregisterormemorylocation.LogicalshiftArithmeticshiftLogicalshifts
multiplyordivide
unsigneddata,andarithmeticshiftsmultiplyordividesigneddata.Ashiftleftmultipliesby2foreachbitpositionshiftedashiftrightdividesby2foreachbitpositionshiftedShiftinstructions
SHLdest,count SHRdest,count SALdest,count SARdest,count ;destisthetargetoperandbeingshiftedusingregisterormemoryaddressingmode ;countisthenumberoftimes(orbits)thattheoperandisshifted,itcanbespecifieddirectlyusinganimmediateshiftcount,orthroughtheCLregister.SHL/SALinstructionSHRinstructionSARinstructionflagsShiftinstructionswillchangeflags:CF:changebyshiftedbitOF:Multiple-bitshift:undefinedSingle-bitshift0:ifthesignbitoftheresultisthesameasthesignbitoftheoriginaloperandvalue.1:theyaredifferentZF,PF:assignedaccordingtoresultAF:undesignedExamplessalcx,1;beforecx=a9d7shrax,1;beforeax=a9d7sarbx,1;beforebx=a9d7salace,4;beforeace=a9d7shrdx,4;beforedx=a9d7sarax,cl;beforeax=a9d7,cl=04;將DX.AX中32位數(shù)值左移一位shlax,1rcldx,1DXAXCF0;把AL最低位送BL最低位,保持AL不變rorbl,1roral,1rclbl,1rolal,1AL、BLCFBLCFALCFAL之D0Figure8.7…leaebx,hexOut+7movecx,8forCount:movedx,eaxandedx,0000000fhcmpedx,9jnleelseLetteroredx,30h
jmpendifDigitelseLetter:addedx,‘A’-10EndifDigit:movBYTEPTR[ebx],dlDecebxshreax,4LoopforCount…Doubleshiftinstructionssh-ddest,src,count-:l(leftshift),r(rightshift)dest:wordordoublewordinaregisterormemorysrc:wordordoublewordinaregistercount:immediateorCLflagsCF:lastbitshiftedoutgoestoCFSF,ZF,PF:assignedcorrespondingtotheresultOF:undefinedExamples:shldecx,eax,12;beforeECX=12345678,EAX=90ABCDEFshrdecx,eax,CL;beforeECX=12345678,EAX=90ABCDEF,CL=08Figure8.7…
leaebx,hexOut
;leaebx,hexOut+7movecx,8forCount:shldedx,eax,4
;movedx,eaxandedx,0000000fhcmpedx,9jnleelseLetteroredx,30hjmpendifDigitelseLetter:addedx,‘A’-10EndifDigit:movBYTEPTR[ebx],dl
incebx
;decebx
shleax,4
;shreax,4loopforCount…Rotateinstructions
rotatedest,count ;rotateisRCL(rotateleftwithcarry),RCR(rotaterightwithcarry),ROL(rotateleft),andROR(rotateright) ;destisthetargetoperandbeingrotatedusingregisterormemoryaddressingmode ;countisthenumberoftimes(orbits)thattheoperandisrotated,itcanbespecifieddirectlyusinganimmediateshiftcount,orthroughtheCLregister.RotateoperationRotateinstructionspositionbinarydatabyrotatingtheinformationinaregisterormemorylocation,eitherfromoneendtoanotherorthroughthecarryflag.Rotateinstructionsareoftenusedtowidenumberstotheleftorright.ROLinstructionRORinstructionRCLinstructionRCRinstruction;將DX.AX中32位數(shù)值左移一位shlax,1rcldx,1DXAXCF0;把AL最低位送BL最低位,保持AL不變rorbl,1roral,1rclbl,1rolal,1AL、BLCFBLCFALCFAL之D0Figure8.7…
leaebx,hexOut+7
;leaebx,hexOutmovecx,8forCount:roleax,4
movedx,eaxandedx,0000000fhcmpedx,9jnleelseLetteroredx,30hjmpendifDigitelseLetter:addedx,‘A’-10EndifDigit:movBYTEPTR[ebx],dl
incebx
;decebx
;shreax,4loopforCount…ASCIItodoubleintegerconversionAtodprocedureatodprocPROCNEAR32pushebp;savebasepointermovebp,esp;establishstackframesubesp,4;localspaceforsignpushebx;Saveregisterspushecxpushedxpushf;saveflagsmovesi,[ebp+8];getparameter(sourceaddr)WhileBlankD:cmpBYTEPTR[esi],'';space?jneEndWhileBlankD;exitifnotincesi;incrementcharacterpointerjmpWhileBlankD;andtryagainEndWhileBlankD:moveax,1;defaultsignmultiplierIfPlusD:cmpBYTEPTR[esi],'+';leading+?jeSkipSignD;ifso,skipoverIfMinusD:cmpBYTEPTR[esi],'-';leading-?jneEndIfSignD;ifnot,savedefault+moveax,-1;-1forminussignSkipSignD:incesi;movepastsignEndIfSignD:mov[ebp-4],eax;savesignmultipliermoveax,0;numberbeingaccumulatedmovcx,0;countofdigitssofarWhileDigitD:cmpBYTEPTR[esi],'0';comparenextcharacterto'0'jlEndWhileDigitD;notadigitifsmallerthan'0'cmpBYTEPTR[esi],'9';compareto'9'jgEndWhileDigitD;notadigitifbiggerthan'9'imuleax,10;multiplyoldnumberby10jooverflowD;exitifproducttoolargemovbl,[esi];ASCIIcharactertoBLandebx,0000000Fh;converttosingle-digitintegeraddeax,ebx;addtosumjcoverflowD;exitifsumtoolargeinccx;incrementdigitcountincesi;incrementcharacterpointerjmpWhileDigitD;gotrynextcharacterEndWhileDigitD:cmpcx,0;nodigits?jzoverflowD;ifso,setoverflowerrorflag;ifvalueis80000000handsignis'-',;wanttoreturn80000000h(-2^32)cmpeax,80000000h;80000000h?jneTooBigD?cmpDWORDPTR[ebp-4],-1;multiplier-1?jeok1D;ifso,return8000hTooBigD?:testeax,eax;checksignflag
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2031年中國水鎂石顆粒行業(yè)投資前景及策略咨詢研究報告
- 2025年型砂項(xiàng)目可行性研究報告
- 2025至2030年中國自動手搖鑰匙復(fù)制機(jī)數(shù)據(jù)監(jiān)測研究報告
- 2025至2030年壓力管件項(xiàng)目投資價值分析報告
- 學(xué)校醫(yī)務(wù)室聘用合同
- 借款居間服務(wù)合同
- 工程招投標(biāo)及合同管理規(guī)范操作手冊
- 股東內(nèi)部承包經(jīng)營合同范本
- 二零二五年度辦事處信息資源共享與風(fēng)險控制合同
- 幼兒園食堂工作人員聘用合同范本
- 安全生產(chǎn)的科技創(chuàng)新與成果轉(zhuǎn)化應(yīng)用
- 過氧乙酸消毒濃度及方法
- 王洪圖黃帝內(nèi)經(jīng)80課時講稿
- 英語課堂游戲PPT-英語游戲4個PPT-(切西瓜-打地鼠-開火車-植物大戰(zhàn)僵尸)
- 大學(xué)物理光學(xué)總結(jié)-大學(xué)物理光學(xué)知識點(diǎn)總結(jié)課件
- 關(guān)于領(lǐng)導(dǎo)干部報告?zhèn)€人有關(guān)事項(xiàng)的規(guī)定全文
- 個人借條電子版模板
- 物業(yè)公司特色服務(wù)、日常增值服務(wù)項(xiàng)目供參考
- 創(chuàng)新創(chuàng)業(yè)實(shí)務(wù)PPT全套完整教學(xué)課件
- 工業(yè)企業(yè)電源快速切換裝置設(shè)計(jì)配置導(dǎo)則
- 某有限公司雙螺紋偏轉(zhuǎn)型防松防盜螺母商業(yè)計(jì)劃書
評論
0/150
提交評論