版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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,顺序执行there:...
TEST指令一般用于检测某些条件是否满足,但又不希望变化原操作数旳情况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位数值左移一位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位数值左移一位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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年合肥滨湖职业技术学院单招职业倾向性测试模拟测试卷附答案
- 2026年技师电工考试题库附答案
- 2026年安徽省池州市单招职业适应性测试题库附答案
- 2026年广西高职单招测试题附答案
- 2026年宜春职业技术学院单招职业适应性测试模拟测试卷附答案
- 2026云南西双版纳州勐海县城乡居民社会养老保险中心招聘城镇公益性岗位人员2人笔试备考试题及答案解析
- 2026黑龙江农业职业技术学院公开招聘博士3人笔试参考题库及答案解析
- 2025年四平市总工会公开招聘工会社会工作者笔试备考题库附答案
- 2025广西梧州市遴选公务员11人备考题库附答案
- 2025广东茂名市信宜市供销合作联社选聘事业编制工作人员1人备考题库附答案
- 甘肃省酒泉市普通高中2025~2026学年度第一学期期末考试物理(含答案)
- 政治●天津卷丨2024年天津市普通高中学业水平选择性考试政治试卷及答案
- GB 30254-2024高压三相笼型异步电动机能效限定值及能效等级
- 盐酸、硫酸产品包装说明和使用说明书
- GB/T 43731-2024生物样本库中生物样本处理方法的确认和验证通用要求
- 2024年部门业务主管自查自纠问题总结及整改措施
- 汽车线束DFMEA设计失效模式和影响分析
- 乌鲁木齐地区2024年高三年级第一次质量监测(一模)英语试卷(含答案)
- plc电梯设计的参考文献
- 中伟西部基地液氨制氨水项目环评报告
- 地下室消防安全制度
评论
0/150
提交评论