




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
上讲总结:使用通用寄存器的load-store cement(withanaddressoffsetsizeof1216bits)immediatesize8to16bitsregistersubtract、moveregister-r pareequal、comparenotequal、branch(withaPC-relativeaddressatleast8-bitslong)、jump、call,以及return;支持如下数据大小和类型:8位、16位、323264IEEE754 固定指令编码方计算机科学技术 微处理器研究开发中
°更课 ,SiliconGraphics,计算机科学技术 微处理器研究开发中 MIPS
°DesignPrinciple:simplicityfavors°OfcoursethiscomplicatessomeC A=B+C+E=F-
MIPS代码
A=B+add$s0,$s1,(编译器完成寄存器与变量的关联
MIPScode:add$t0,$s1,add$s0,$t0,sub$s4,$s5,°Operandsmustberegisters,only32registers°DesignPrinciple:smalleris °Arithmeticinstructionsoperandsmustbeonly32registers°Compilerassociatesvariableswith°Whataboutprogramswithlotsof
Memory°Viewedasalarge,single-dimensionarray,withan°Amemoryaddressisanindexintothe°"Byteaddressing"meansthattheindexpointsabyteof88bitsof8bitsof8bitsof8bitsof8bitsof8bitsof8bitsof12345计算机科
微处理器研究开发
计算机科
微处理器研究开发Memory°Bytesarenice,butmostdataitemsuselarger°ForMIPS,awordis32bitsor43232bitsof32bitsof32bitsof32bitsof
°LoadandstoreC A[8]=h+48
Registershold32bitsof
MIPScode:lw$t0,add$t0,$s2,sw$t0,°232byteswithbyteaddressesfrom0to232-°230wordswithbyteaddresses0,4,8,...232-°Wordsarei.e.,whataretheleast2significantbitsofaword
°Storewordhasdestination°Rememberarithmeticoperandsareregisters,notOurFirst°Canwefigureoutthe
Sofarwehaveswap(intv[],int{inttemp=v[k]v[k]=v[k+1];v[k+1]=}
loadingwordsbutaddressingarithmeticonregisters muli$2,$5,4add$2,$4,$2lw$15,0($2)lw$16,4($2)sw$16,0($2)sw$15,4($2)jr$31
add$s1,$s2,$s3sub$s1,$s2,$s3lw$s1,100($s2)sw$s1,100($s2)
$s1=$s2+$s1=$s2-$s1=Memory[$s2+100]=计算机科学技术 微处理器研究开发中 计算机科学技术 微处理器研究开发中Machine Machine°Instructions,likeregistersandwordsofdata,arealso32bitsExample:add$t0,$s1,registershavenumbers,$t0=9,$s1=17,°Instruction°Canyouguesswhatthefieldnamesstand
°Considertheload-wordandstore-wordWhatwouldtheregularityprinciplehaveusNewprinciple:Gooddesigndemandsa°IntroduceanewtypeofinstructionI-typefordatatransferotherformatwasR-typefor°Example:lw$t0,916bitWhere'sthe °Instructionsare°Programsarestoredinmemorytobereadorwrittenjustlikememoryfordata,
°Decisionmakingalterthecontroli.e.,changethe"next"instructiontobe°Fetch&Execute
compilers,editors,
°MIPSconditionalbranchbne$t0,$t1,beq$t0,$t1,InstructionsarefetchedandputintoaspecialBitsintheregister"control"thesubsequentFetchthenextinstructionand计算机科学技术 微处理器研究开发中
if(i==j)h=i+bne$s0,$s1,add$s3,$s0,$s1 计算机科
微处理器研究开发°MIPSunconditionalbranchj
Soadd$s1,$s2,$s3sub$s1,$s2,$s3lw$s1,100($s2)sw$s1,100($s2)bne$s4,$s5,L
$s1=$s2+$s1=$s2-$s1=Memory[$s2+100]=Nextinstr.isatLabelif$s4if
beq$s4,$s5,Lab1add$s3,$s4,$s5jLab2Lab1:sub$s3,$s4,$s5
beqj
Nextinstr.isatLabelif$s4=$s5Nextinstr.isatLabel16bit26bitIJ°CanyoubuildasampleforIJControl°Wehave:beq,bne,whataboutBranch-if-less-°Newslt:setonless°slt$t0,$s1,$s2if$s1<$s2then$t0=$t0=°Canusethisinstructiontobuild"blt$s1,$s2,cannowbuildgeneralcontrol°Notethattheassemblerneedsaregistertodothis,thereare ofuseconventionsforregisters
ofUse0计算机科
微处理器研究开发中
计算机科学技术 微处理器研究开发中
Howaboutlarger°Smallconstantsareusedquitefrequently(50%of A=A+B=B+C=C-
°We'dliketobeabletoloada32bitconstantintoa°Mustusetwoinstructions,new"loadupperimmediate"lui$t0,°Solutions?Whyput'typicalconstants'inmemoryandloadcreatehard-wiredregisters(like$zero)forconstantslike°MIPSaddi$29,$29,4slti$8,$18,10andi$29,$29,6ori$29,$29,°Howdowemakethis
°Thenmustgetthelowerorderbitsright,ori$t0,
filledwith
AddressesinBranchesand°Assemblyprovidesconvenientsymbolicmucheasierthanwritingdowne.g.,destination°Machinelanguageistheunderlyinge.g.,destinationisnolonger°Assemblycanprovide'pseudoe.g.,Move$t0,$t1existsonlyinwouldbeimplementedusingAdd°Whenconsideringperformanceyoushouldcountrealinstructions
bne$t4,$t5,LabelNextinstructionisatLabelif$t4$t5beq$t4,$t5,LabelNextinstructionisatLabelif$t4=$t5jLabel NextinstructionisatLabel16bit26bit°Addressesarenot32-Howdowehandlethiswithloadandstore计算机科学技术 微处理器研究开发中 计算机科学技术 微处理器研究开发中bne$t4,$t5,LabelNextinstructionisatLabelif$t4
MIPSR2000/R3000的寄00beq$t4,$t5,LabelNextinstructionisatLabelif$t416bit°Couldspecifyaregister(likelwandsw)andaddittouseInstructionAddressRegister(PC=programmostbranchesarelocal(principleof°Jumpinstructionsjustusehighorderbitsofaddressboundariesof256
°可编232x31x32-bitGPRs(R032x32-bitFPHI,LO,
..MIPS的寻址方式/指令Register++
MIPSR2000/R3000的操Add,AddU, SubU,And,Or,Nor,SLT,AddI,AddIU,SLTI,SLTIU,AndI,OrI,XorI,SLL,SRL,SRA,SLLV,SRLV, (MemoryLB,LBU,LH,LHU,LW,SB,SH,SW,SWL,计算机科学技术 微处理器研究开发中 计算机科学技术 微处理器研究开发中°Startmultiply,MULTrs,MULTUrs,DIVrs,DIVUrs,°MovefromHIorMFHIMFLO°MovetoHIorMTHIMTLO
MIPS的算术 add$1,$2,$3 $1=$2+$3 3operands;exceptionpossible sub$1,$2,$3 $1=$2-$3 3operands;exceptionpossibleaddimmediate addi$1,$2,100 $1=$2+100 +constant;exceptionpossibleaddunsigned addu$1,$2,$3 $1=$2+$3 3operands;noexceptionssubtractunsigned subu$1,$2,$3 $1=$2-$3 3operands;noexceptionsaddimm.unsign. addiu$1,$2,100 $1=$2+100 +constant;noexceptions mult$2,$3 Hi,Lo=$2x$3 64-bitsignedproductmultiplyunsigned Hi,Lo=$2x$3 64-bitunsignedproduct div$2,$3 Lo=$2÷$3, Lo=quotient,Hi=remainderHi=$2moddivide divu Lo=$2 Unsignedquotient&Hi=$2modMovefromHi mfhi$1 $1=Hi UsedtogetcopyofHiMovefrom mflo $1= UsedtogetcopyofMIPS的逻辑
OperandSizeandand$1=$2&3reg.operands;Logicalor$1=$2|3reg.operands;Logicalxor$1=$23reg.operands;Logicalnor$1=~($23reg.operands;Logicalandandi$1=$2&LogicalANDreg,orori$1=$2|LogicalORreg,xorxori$1,$1=~$2LogicalXORreg,shiftleftsll$1=$2<<Shiftleftbyshiftrightsrl$1=$2>>Shiftrightbyshiftrightsra$1=$2>>Shiftright(signshiftleftsllv$1=$2<<Shiftleftbyshiftrightsrlv$1,$2,$1=$2>>Shiftrightbyshiftrightsrav$1,$2,$1=$2>>Shiftrightarith.by
IntIntFP Frequencyofreferenceby
计算机科学技术 微处理器研究开发中
Supportthesedatasizesand8-bit,16-bit,32-bitintegers32-bitand64-bitIEEE754floatingpoint计算机科学技术 微处理器研究开发中MIPS的数据
ConditionalBranchSW500(R4),R3SH502(R2),R3SB41(R3),R2LWR1,
StorewordStorehalfStorebyteLoad
PC-relativesincemostbranchestothecurrentPCaddressAtleast8bitssuggested(128IntFPCompareEqual/NotEqualmostimportantIntFPLHR1,40(R3)LHUR1,40(R3)LBR1,40(R3)LBUR1,40(R3)
LoadLoadhalfwordLoadLoadbyte
LUIR1, LoadUpperImmediate(16bitsshiftedleftby计算机科学技术 微处理器研究开发中
Frequencyof计算机科学技术系typesin
微处理器研究开发°比较并转
BEQrs,rt,BNErs,rt,°与零比较并转BLEZrs,BGTZrs,BLTZALrs,
ifR[rs]==R[rt]thenPC-relativeifR[rs]<=0thenPC-relative><IfR[rs]<0thenbranchandlink(intoR
branchonequalbranchonnoteq.setonlessthansetlessthanimm.setlessthanuns.setl.t.imm.uns.
beqEqualtest;PCrelativebneNotequaltest;PCslt;slti<;sltu;sltiu;
if($1==$2)gotoif($1!=$2)goto if($2<$3)$1=1;else$1=0if($2<100)$1=1;else$1=0if($2<$3)$1=1;else$1=0if($2<100)$1=1;else$1=0°其他的比较并转移需要两条指
jjump jr
gotogoto°几乎所有的比较是计算机科
进行比
微处理器研究开发
jumpand jal $31=PC+4;gotoprocedure计算机科学技术 微处理器研究开发中
从程 系统中获得指
确定后续指
branchonequalbranchonnoteq.
beqEqualtest;PCrelativebneNotequaltest;PC
if($1==$2)gotoif($1!=$2)goto 确定所需的动作和指令
定位并获得操作数数计算结果数值或状 系统中存放结果,以备后
branchon beqbranchonnot bne
if($1==$2)goto Equaltest;PCrelativeif($1!=$2)goto Notequaltest;PCAACBABACBABA
器堆栈(Memory即使操作数堆栈不是系统结构的组成部分,也有益于栈式环境(stacked以 子程序调用和返 CALL
堆栈为空表明什么
inf.abcabc0
0 inf.一些机器提供一 器堆栈(memorystack),并将此作为系统结构的一部
BAALittle-->Big/LastBAA
Little-->Big/Next(例如,一些机器堆栈是利用软件来实(例如,
ReadfromMem(SP)DecrementSPIncrementSPWritetoMem(SP)
ReadfromWritetoIncrement计算机科学技术 微处理器研究开发中
计算机科
微处理器研究开发 :Stack
High
(oldFP,Local(oldFP,Localfrom2expressionevaluation3function456
zeroconstant for
16s0callee...(callercan在表达式估值过程中,伸
temporary(caller77Pointertoglobal8Stack°堆栈有许多可能的变种(up/down,lastpushed/next
Low
.. (calleecan15
30fpframe31raReturnAddress°BlockstructuredlanguagescontainlinktolexicallyenclosingMIPS/addiu$sp,$sp,-32 addiu$fp,$sp,.. $a0,
C示例:swap(intv[],int{inttemp;temp=v[k];v[k]=v[k+1];v[k+1]=temp;}lwlw$fp,16($sp)addiu$sp,$sp,32jr$31计算机科
old微处理器研究开发
$16是中间使用的寄存器(scratchMIPS代码计算机科学技术
微处理器研究开发
Branch&lir3,#7subr4,r4,addir5,r3,
Delay$sp,$sp,-;create$sp,$sp,-;createspaceon$16,;calleesavedregisterputonto$t2,;mulitplykby$t2,;addressof$15,;load$16,;load$16,;storev[k+1]into$15,;storeoldvalueofv[k]into$16,;calleesavedregisterrestoredfrom$sp,$sp,;restoretopof
Branch ;return cethatcalled
BytheendofBranchinstruction,theCPUknowswhetherornotthebranchwilltake However,itwillhavefetchedthenextinstructionbyregardlessofwhetherornotabranchwillbetaken.Whynotexecuteit?FillingDelayed
&Dcd&Dcd&OpInstInstexecutesuccessorevenifbranchInstThenbranchor
Dcd&Dcd&OpInstSingledelayslotimpactsthecriticalpath
Compilercanfillasingledelayslotwithausefulinstruction50%ofthetrytomovedownfromabove
addr3,r1,r2subr4,r4,1bzr4,LL
,moveupfromtarget,if addrd,Isthisviolatingthe
无论这个转移是否真的发生,它都将访取下一条指令计算机科学技术 微处理器研究开发中 计算机科学技术 微处理器研究开发中Dcd&Dcd&OpInst
MIPS的其他指Dcd&OpInstDcd&OpInstInstThenbranchorcontinue Singledelayslotimpactsthecriticalpath
°coprocessor°TLB
Abreakpointtrapoccurs,transferscontroltoexceptionhandlerAsystemtrapoccurs,transferscontroltoexceptionhandlerSupportforfloatingpoint:discussedlaterSupportforvirtualmemory:discussedlater试图从跳转之前,移动下来指如果安全,可以从目标出移动来指
addr3,r1,subr4,r4,1bzr4,LLLL:addrd,
°restorefrom°loadword°storeword
Restorespreviousinterruptmask&kernel/usermodebitsintostatusregisterSupportsmisalignedwordloadsSupportsmisalignedwordstores°#0寄存器总是具有数值0(即使试图对它写入其他数值,也是如此°转移和跳转指令将返回地址PC+4装 寄存器(link°所有指令改变目标寄存器的所有32位信息(包括lui,lb,lh),并 的所有32位信息(add,sub,and,or,等等)°立即数算术和逻辑指令进行如下扩展逻辑立即数(logical 零扩展到32算术立即数(arithmeticimmediates)符号扩展到32°指令lblh装入的数据进行如下扩展lbu,lhu是零扩lb 是符号扩°下面的算术和逻辑指令可能会出现溢出add,sub,以下指令不会出现溢出addusubu,addiuand,orxor,norshifts,mult,multu,div,divu
°Designprovidemorepowerfulgoalistoreducenumberofinstructionsdangerisaslowercycletimeand/orahigher°SometimesreferredtoasRISCvs.virtuallyallnewinstructionsetssince1982havebeenVAX:minimizecodesize,makeassemblylanguageinstructionsfrom1to54bytes°WewilllookatPowerPCand计算机科学技术 微处理器研究开发中 计算机科学技术 微处理器研究开发中°Indexed lwWhatdowehavetodoin°Update
°1978:The 8086isannounced(16bit°1980:The8087floatingpointcoprocessoris°1982:The80286increasesaddressspaceto24bits,°1985:The80386extendsto32bits,newaddressingupdatearegisteraspartofload(formarchingthroughlwu$t0,4($s3)Whatdowehavetodoinloadmultiple/storeaspecialcounterregisterbcdecrementcounter,ifnot0goto
°1989-1995:The80486,Pentium,PentiumProaddafewinsts(mostlydesignedforhigherperformance)°1997:MMXis°1997-2000:PentiumII,PentiumIII,PentiumThishistorytheimpactoftheGoldenhandcuffsofAnarchitecturethatisdifficultto inandimpossibleto 8086/88=>80286=>80386=>80486=>Pentium=>PentiumPro8086只能使用不多的晶体管,因而它只实现了16位微处理试图与8位8080微处理器比较兼在8086的后续微处理器中,不断增加了许多新的功许多不同的计算机工程师的成1978年宣°VAX简单的编&小代码空间高效的指令强大的寻址强大的寄存器一位出色设计师的1977年宣计算机科学技术 微处理器研究开发中
Adominantarchitecture:°SeeyourtextbookforamoredetailedInstructionsfrom1to17bytesoneoperandmustactasbothasourceandoneoperandcancomefromcomplexaddressinge.g.,Baseorscaledindexwith8or32bit °SavingthemostfrequentlyusedinstructionsarenottoodifficulttocompilersavoidtheportionsofthearchitecturethatareWhatthe80x86lacksinstyleismadeupin makingitbeautifulfromtheright计算机科学技术 微处理器研究开发中机器示例:地址与寄存
VAX
220x8bitbytesAX,BX,CX,
acc,index,count
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 南昌大学《小学科学活动设计与指导》2023-2024学年第二学期期末试卷
- 杭州科技职业技术学院《旅行社经营实务》2023-2024学年第二学期期末试卷
- 新疆政法学院《复合材料力学》2023-2024学年第二学期期末试卷
- 哈尔滨幼儿师范高等专科学校《能源动力(动力工程)领域工程伦理》2023-2024学年第二学期期末试卷
- Starter Unit 1 Section B 1a-1e 教学设计 2024-2025学年人教版英语七年级上册
- Unit 2 What time is it Part A Let's learn(教学设计)-2023-2024学年人教PEP版英语四年级下册
- 常州幼儿师范高等专科学校《医学遗传学基础》2023-2024学年第二学期期末试卷
- Unit 6 My week Lesson 2 Activities in a week(教学设计)-2024-2025学年人教新起点版英语二年级下册
- 沧州2025年河北沧州市人民医院第一批招聘119人笔试历年参考题库附带答案详解
- ★试题:决策过程及其思维特点、科学决策与科学思维的关系
- 2025年不停电电源(UPS)项目合作计划书
- 2025年国家林业和草原局直属事业单位第一批招聘应届毕业生96人历年高频重点模拟试卷提升(共500题附带答案详解)
- 2025年春季开学典礼校长讲话稿-少年无畏凌云志扶摇直上入云苍
- 2025寒假开学第一课 课件【1】
- 山东省泰安市新泰市2024-2025学年(五四学制)九年级上学期1月期末道德与法治试题(含答案)
- 1《北京的春节》课后练习(含答案)
- (完整版)陆河客家请神书
- 2025年行业协会年度工作计划
- DB3502T 160-2024 工业产品质量技术帮扶和质量安全监管联动工作规范
- 2025年学校教师政治理论学习计划
- 集团专利管理制度内容
评论
0/150
提交评论