AND指令可用于復位某些位(同0相與)_第1頁
AND指令可用于復位某些位(同0相與)_第2頁
AND指令可用于復位某些位(同0相與)_第3頁
AND指令可用于復位某些位(同0相與)_第4頁
AND指令可用于復位某些位(同0相與)_第5頁
已閱讀5頁,還剩33頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

Chapter8BitManipulationContents:LogicalOperationsShiftandRotateInstructions8.1LogicalOperationsANDdestination,sourceTESTdestination,sourceThesameasANDinstructionbutnotchangedestinationNOTdestinationORdestination,sourceinclusiveXORdestination,sourceexclusiveTruetableABT000010100111ANDsrcregmemimmreg√√√mem√√destABT000011101110ABT000011101111AT0110flagsLogicaloperationexceptforNOTwillaffectflagregister.CF=0OF=0AF:undefinedPF,SF,ZF:setbythevalueofresult.Clearselectedbits(marking)ClearallbutthelastfourbitsinEAXANDeax,0000000fhSetselectedbitsSetallbutthelastfourbitsinEAXOReax,fffffff0hnegateselectedbitsnegateallbutthelastfourbitsinEAXXOReax,fffffff0hXoreax,eax;AND指令可用于復位某些位(同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 ;標志ZF=0,即D0=1 ;則程序轉移到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)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論