首页 MIPS体系结构(北大课件)

MIPS体系结构(北大课件)

举报
开通vip

MIPS体系结构(北大课件) 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS指令系统体系结构 MIPS Instruction Set Architecture 计算机组织与系统结构计算机组织与系统结构 (第五讲 ) 2003.10.9 程 旭 北京大学计算机科学技术系 北京大学微处理器研究开发中心 本讲概况 �上讲复习 �MIPS指令系统体系结构 �MIPS的其他情况 �MIPS (PowerPC、VAX、80x86) 北京大学计算机科学技术系 北京大学微处理器研究开发中心 指令系统设计 指令系统 软...

MIPS体系结构(北大课件)
北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS指令系统体系结构 MIPS Instruction Set Architecture 计算机组织与系统结构计算机组织与系统结构 (第五讲 ) 2003.10.9 程 旭 北京大学计算机科学技术系 北京大学微处理器研究开发中心 本讲概况 �上讲复习 �MIPS指令系统体系结构 �MIPS的其他情况 �MIPS (PowerPC、VAX、80x86) 北京大学计算机科学技术系 北京大学微处理器研究开发中心 指令系统设计 指令系统 软件 硬件 北京大学计算机科学技术系 北京大学微处理器研究开发中心 执行周期 Instruction Fetch Instruction Decode Operand Fetch Execute Result Store Next Instruction 从程序存储系统中获得指令 确定所需的动作和指令大小 定位并获得操作数数据 计算结果数值或状态 在存储系统中存放结果,以备后用 确定后续指令 北京大学计算机科学技术系 北京大学微处理器研究开发中心 • 使用通用寄存器的load-store 结构; • 支持如下寻址方式:displacement (with an address offset size of 12 to 16 bits)、 immediate (size 8 to 16 bits), 以及 register deferred; • 支持如下简单指令(因为它们决定执行的指令总数):load、store、add、 subtract、move register-register、and、shift、compare equal、 compare not equal、 branch (with a PC-relative address at least 8-bits long)、 jump、 call, 以及return; • 支持如下数据大小和类型:8位、16位、32位整数; 以及 32位和 64位 IEEE 754 浮点数 • 如果看重性能,就使用 固定指令编码 方案 气瓶 现场处置方案 .pdf气瓶 现场处置方案 .doc见习基地管理方案.doc关于群访事件的化解方案建筑工地扬尘治理专项方案下载 如果看重代码大小,就使用 可变指令编码方案 • 提供至少16个通用寄存器,以及单独的浮点寄存器; • 确信所有的寻址方式都可以用于所有的数据传输指令; • 瞄准最低限要求的指令系统 上讲 总结 初级经济法重点总结下载党员个人总结TXt高中句型全总结.doc高中句型全总结.doc理论力学知识点总结pdf : ISA 北京大学计算机科学技术系 北京大学微处理器研究开发中心 指令(Instructions): °机器语言的字词 °比高级语言更加简单、原始 例如,没有复杂的控制流 °限制性非常强 例如:MIPS算术运算指令 °更课程我们将基于MIPS指令系统体系结构 • 与二十世纪八十年代后的许多结构都很类似:NEC, Nintendo, Silicon Graphics, Sony 设计目标: 更高性能、更低成本、更少设计周期 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS 算术指令 °所有算术指令都有 3 个操作数 °操作数的次序是固定的(目标操作数领先) 示例: C代码: A = B + C MIPS代码: add $s0, $s1, $s2 (编译器完成寄存器与变量的关联) 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS arithmetic °Design Principle: simplicity favors regularity. Why? °Of course this complicates some things... C code: A = B + C + D; E = F - A; MIPS code: add $t0, $s1, $s2 add $s0, $t0, $s3 sub $s4, $s5, $s0 °Operands must be registers, only 32 registers provided °Design Principle: smaller is faster. Why? 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Registers vs. Memory Processor I/O Control Datapath Memory Input Output °Arithmetic instructions operands must be registers, • only 32 registers provided °Compiler associates variables with registers °What about programs with lots of variables 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Memory Organization ° Viewed as a large, single-dimension array, with an address. ° A memory address is an index into the array ° "Byte addressing" means that the index points to a byte of memory. 0 1 2 3 4 5 6 ... 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 8 bits of data 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Memory Organization °Bytes are nice, but most data items use larger "words" °For MIPS, a word is 32 bits or 4 bytes. °232 bytes with byte addresses from 0 to 232-1 °230 words with byte addresses 0, 4, 8, ... 232-4 °Words are aligned i.e., what are the least 2 significant bits of a word address? ... 0 4 8 12 32 bits of data 32 bits of data 32 bits of data 32 bits of data Registers hold 32 bits of data 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Instructions °Load and store instructions °Example: C code: A[8] = h + A[8]; MIPS code: lw $t0, 32($s3) add $t0, $s2, $t0 sw $t0, 32($s3) °Store word has destination last °Remember arithmetic operands are registers, not memory! 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Our First Example °Can we figure out the code? swap(int v[], int k); { int temp; temp = v[k] v[k] = v[k+1]; v[k+1] = temp; } swap: muli $2, $5, 4 add $2, $4, $2 lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) jr $31 Assume: k->$5 v[0]->$4 北京大学计算机科学技术系 北京大学微处理器研究开发中心 So far we have learned: °MIPS - loading words but addressing bytes - arithmetic on registers only °Instruction Meaning add $s1, $s2, $s3 $s1 = $s2 + $s3 sub $s1, $s2, $s3 $s1 = $s2 - $s3 lw $s1, 100($s2) $s1 = Memory[$s2+100] sw $s1, 100($s2) Memory[$s2+100] = $s1 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °Instructions, like registers and words of data, are also 32 bits long • Example: add $t0, $s1, $s2 • registers have numbers, $t0=9, $s1=17, $s2=18 °Instruction Format: 000000 10001 10010 01000 00000 100000 op rs rt rd shamt funct °Can you guess what the field names stand for? Machine Language 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °Consider the load-word and store-word instructions, • What would the regularity principle have us do? • New principle: Good design demands a compromise °Introduce a new type of instruction format • I-type for data transfer instructions • other format was R-type for register °Example: lw $t0, 32($s2) 35 18 9 32 op rs rt 16 bit number Where's the compromise? Machine Language 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °Instructions are bits °Programs are stored in memory to be read or written just like data °Fetch & Execute Cycle • Instructions are fetched and put into a special register • Bits in the register "control" the subsequent actions • Fetch the next instruction and continue Processor Memory memory for data, programs, compilers, editors, etc. Stored Program Concept 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °Decision making instructions • alter the control flow, • i.e., change the "next" instruction to be executed °MIPS conditional branch instructions: bne $t0, $t1, Label beq $t0, $t1, Label °Example: if (i==j) h = i + j; bne $s0, $s1, Label add $s3, $s0, $s1 Label: .... Control 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °MIPS unconditional branch instructions:j label °Example: if (i!=j) beq $s4, $s5, Lab1 h=i+j; add $s3, $s4, $s5 else j Lab2 h=i-j; Lab1:sub $s3, $s4, $s5 Lab2:... °Can you build a sample for loop? Control 北京大学计算机科学技术系 北京大学微处理器研究开发中心 So far: °Instruction Meaning add $s1,$s2,$s3 $s1 = $s2 + $s3 sub $s1,$s2,$s3 $s1 = $s2 - $s3 lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1 bne $s4,$s5,L Next instr. is at Label if $s4 ≠ $s5 beq $s4,$s5,L Next instr. is at Label if $s4 = $s5 j Label Next instr. is at Label °Formats: op rs rt rd shamt funct op rs rt 16 bit address op 26 bit address R I J 北京大学计算机科学技术系 北京大学微处理器研究开发中心 ° We have: beq, bne, what about Branch-if-less-than? ° New instruction: slt : set on less than ° slt $t0, $s1, $s2 if $s1 < $s2 then $t0 = 1 else $t0 = 0 ° Can use this instruction to build "blt $s1, $s2, Label" can now build general control structures ° Note that the assembler needs a register to do this, there are policy of use conventions for registers 2 Control Flow 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Policy of Use Conventions $zero 0 the constant value 0 $v0-$v1 2-3 values for results and expression evaluat $a0-$a3 4-7 arguments $t0-$t7 8-15 temporaries $s0-$s7 16-23 saved $t8-$t9 24-25 more temporaries $gp 28 global pointer $sp 29 stack pointer $fp 30 frame pointer $ra 31 return address 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °Small constants are used quite frequently (50% of operands) e.g., A = A + 5; B = B + 1; C = C - 18; °Solutions? Why not? • put 'typical constants' in memory and load them. • create hard-wired registers (like $zero) for constants like one. °MIPS Instructions: addi $29, $29, 4 slti $8, $18, 10 andi $29, $29, 6 ori $29, $29, 4 °How do we make this work? Constants 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °We'd like to be able to load a 32 bit constant into a register °Must use two instructions, new "load upper immediate" instruction lui $t0, 1010101010101010 °Then must get the lower order bits right, i.e., ori $t0, $t0, 1010101010101010 1010101010101010 0000000000000000 0000000000000000 1010101010101010 1010101010101010 1010101010101010 ori 1010101010101010 0000000000000000 filled with zeros How about larger constants? 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °Assembly provides convenient symbolic representation • much easier than writing down numbers • e.g., destination first °Machine language is the underlying reality • e.g., destination is no longer first °Assembly can provide 'pseudo instructions' • e.g., Move $t0, $t1 exists only in Assembly • would be implemented using Add $t0,$t1,$zero °When considering performance you should count real instructions Assembly Language vs. Machine Language 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °Instructions: bne $t4,$t5,Label Next instruction is at Label if $t4 ≠ $t5 beq $t4,$t5,Label Next instruction is at Label if $t4 = $t5 j Label Next instruction is at Label °Formats: °Addresses are not 32 bits - How do we handle this with load and store instructions? op rs rt 16 bit address op 26 bit address I J Addresses in Branches and Jumps 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °Instructions: bne $t4,$t5,LabelNext instruction is at Label if $t4 ≠ t5 beq $t4,$t5,LabelNext instruction is at Label if $t4 =$t5 °Formats: °Could specify a register (like lw and sw) and add it to address • use Instruction Address Register (PC = program counter) • most branches are local (principle of locality) °Jump instructions just use high order bits of PC • address boundaries of 256 MB op rs rt 16 bit addressI Addresses in Branches 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS R2000 / R3000 的寄存器 °可编程存储 • 232 x bytes • 31 x 32-bit GPRs (R0 ≡ 0) • 32 x 32-bit FP regs (数据处理成对:paired DP) • HI, LO, PC 0r0 r1 . r31 PC lo hi .. 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS 的寻址方式/指令格式 Register (direct) Base+index Immediate PC-relative op rs rt rd immed register op rs rt register + Memory immedop rs rt immedop rs rt PC + Memory 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS R2000 / R3000 的操作 °算术逻辑类(Arithmetic logical) • Add, AddU, Sub, SubU, And, Or, Xor, Nor, SLT, SLTU • AddI, AddIU, SLTI, SLTIU, AndI, OrI, XorI, LUI • SLL, SRL, SRA, SLLV, SRLV, SRAV °存储器访问(Memory Access) • LB, LBU, LH, LHU, LW, LWL,LWR • SB, SH, SW, SWL, SWR 北京大学计算机科学技术系 北京大学微处理器研究开发中心 乘法 / 除法 °Start multiply, divide • MULT rs, rt • MULTU rs, rt • DIV rs, rt • DIVU rs, rt °Move from HI or LO • MFHI rd • MFLO rd °Move to HI or LO • MTHI rd • MTLO rd Registers HI LO 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS 的算术指令 指令 示例 含义 注释 add add $1,$2,$3 $1 = $2 + $3 3 operands; exception possible subtract sub $1,$2,$3 $1 = $2 -$3 3 operands; exception possible add immediate addi $1,$2,100 $1 = $2 + 100 + constant; exception possible add unsigned addu $1,$2,$3 $1 = $2 + $3 3 operands; no exceptions subtract unsigned subu $1,$2,$3 $1 = $2 -$3 3 operands; no exceptions add imm. unsign. addiu $1,$2,100 $1 = $2 + 100 + constant; no exceptions multiply mult $2,$3 Hi, Lo = $2 x $3 64-bit signed product multiply unsigned multu$2,$3 Hi, Lo = $2 x $3 64-bit unsigned product divide div $2,$3 Lo = $2 ÷$3, Lo = quotient, Hi = remainder Hi = $2 mod $3 divide unsigned divu $2,$3 Lo = $2 ÷$3, Unsigned quotient & remainder Hi = $2 mod $3 Move from Hi mfhi $1 $1 = Hi Used to get copy of Hi Move from Lo mflo $1 $1 = Lo Used to get copy of Lo 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS 的逻辑指令 指令 示例 含义 注释 and and $1,$2,$3 $1 = $2 & $3 3 reg. operands; Logical AND or or $1,$2,$3 $1 = $2 | $3 3 reg. operands; Logical OR xor xor $1,$2,$3 $1 = $2 ⊕ $3 3 reg. operands; Logical XOR nor nor $1,$2,$3 $1 = ~($2 |$3) 3 reg. operands; Logical NOR and immediate andi $1,$2,10 $1 = $2 & 10 Logical AND reg, constant or immediate ori $1,$2,10 $1 = $2 | 10 Logical OR reg, constant xor immediate xori $1, $2,10 $1 = ~$2 &~10 Logical XOR reg, constant shift left logical sll $1,$2,10 $1 = $2 << 10 Shift left by constant shift right logical srl $1,$2,10 $1 = $2 >> 10 Shift right by constant shift right arithm. sra $1,$2,10 $1 = $2 >> 10 Shift right (sign extend) shift left logical sllv $1,$2,$3 $1 = $2 << $3 Shift left by variable shift right logical srlv $1,$2, $3 $1 = $2 >> $3 Shift right by variable shift right arithm. srav $1,$2, $3 $1 = $2 >> $3 Shift right arith. by variable 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Operand Size Usage Frequency of reference by size 0% 20% 40% 60% 80% Byte Halfword Word Doubleword 0% 0% 31% 69% 7% 19% 74% 0% Int Avg. FP Avg. •Support these data sizes and types: 8-bit, 16-bit, 32-bit integers and 32-bit and 64-bit IEEE 754 floating point numbers 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS 的数据传输指令 指令 注释 SW 500(R4), R3 Store word SH 502(R2), R3 Store half SB 41(R3), R2 Store byte LW R1, 30(R2) Load word LH R1, 40(R3) Load halfword LHU R1, 40(R3) Load halfword unsigned LB R1, 40(R3) Load byte LBU R1, 40(R3) Load byte unsigned LUI R1, 40 Load Upper Immediate (16 bits shifted left by 16) 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Conditional Branch Addressing •PC-relative since most branches to the current PC address • At least 8 bits suggested (128 instructions) • Compare Equal/Not Equal most important for integer programs (86%) Frequency of comparison types in branches 0% 50% 100% EQ/NE GT/LE LT/GE 37% 23% 40% 86% 7% 7% Int Avg. FP Avg. 北京大学计算机科学技术系 北京大学微处理器研究开发中心 比较并转移 °比较并转移 • BEQ rs, rt, offset if R[rs] == R[rt] then PC-relative branch • BNE rs, rt, offset <> °与零比较并转移 • BLEZ rs, offset if R[rs] <= 0 then PC-relative branch • BGTZ rs, offset > • BLT < • BGEZ >= • BLTZAL rs, offset If R[rs] < 0 then branch and link (into R 31) • BGEZAL >= °其他的比较并转移 需要两条指令 °几乎所有的比较 都是与 进行比较! 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS 的跳转(jump)、转移(branch)、比较(compare)指令 指令 示例 含义 branch on equal beq $1,$2,100 if ($1 == $2) go to PC+4×100 Equal test; PC relative branch branch on not eq. bne $1,$2,100 if ($1!= $2) go to PC+4 × 100 Not equal test; PC relative set on less than slt $1,$2,$3 if ($2 < $3) $1=1; else $1=0 Compare less than; 补码. set less than imm. slti $1,$2,100 if ($2 < 100) $1=1; else $1=0 Compare < constant; 补码. set less than uns. sltu $1,$2,$3 if ($2 < $3) $1=1; else $1=0 Compare less than; 自然数 set l. t. imm. uns. sltiu $1,$2,100 if ($2 < 100) $1=1; else $1=0 Compare < constant; 自然数 jump j 10000 go to 10000 跳转到目标地址 jump register jr $31 go to $31 用于switch, procedure return jump and link jal 10000 $31 = PC + 4; go to 10000 用于 procedure call 北京大学计算机科学技术系 北京大学微处理器研究开发中心 执行周期 从程序存储系统中获得指令 确定所需的动作和指令大小 定位并获得操作数数据 计算结果数值或状态 在存储系统中存放结果,以备后用 确定后续指令 Instruction Fetch Instruction Decode Operand Fetch Execute Result Store Next Instruction Instruction Fetch Instruction Decode Operand Fetch Execute Result Store Next Instruction 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS 的跳转(jump)、转移(branch)、比较(compare)指令 指令 示例 含义 branch on equal beq $1,$2,100 if ($1 == $2) go to PC+4×100 Equal test; PC relative branch branch on not eq. bne $1,$2,100 if ($1!= $2) go to PC+4 × 100 Not equal test; PC relative branch on equal beq $1,$2,100 if ($1 == $2) goto PC+4×100+4 Equal test; PC relative branch branch on not eq. bne $1,$2,100 if ($1!= $2) goto PC+4 × 100+4 Not equal test; PC relative 北京大学计算机科学技术系 北京大学微处理器研究开发中心 为什么堆栈非常重要? 子程序调用&返回时的堆栈操作和环境: A: CALL B CALL C C: RET RET B: A A B A B C A B A 一些机器提供一个存储器堆栈(memory stack), 并将此作为系统结构的一部分 (例如, VAX) 一些机器堆栈是利用软件来实现的 (例如, MIPS) 北京大学计算机科学技术系 北京大学微处理器研究开发中心 存储器堆栈(Memory Stacks) 即使操作数堆栈不是系统结构的组成部分, 也有益于 栈式环境( stacked environments), 以及 子程序调用和返回 向上增长的堆栈 vs. 向下增长的堆栈: a b c 0 Little inf. Big 0 Little inf. Big 存储器 地址 SP Next Empty? Last Full? 堆栈为空 关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf 明什么? Little --> Big/Last Full POP: Read from Mem(SP) Decrement SP PUSH: Increment SP Write to Mem(SP) 向上增长 向下增长 Little --> Big/Next Empty POP: Decrement SP Read from Mem(SP) PUSH: Write to Mem(SP) Increment SP 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Call-Return链接: Stack Frames FP ARGS Callee Save Registers Local Variables SP Reference args and local variables at fixed (positive) offset from FP 在表达式估值过程中, 伸缩 (old FP, RA) °堆栈有许多可能的变种 (up/down, last pushed / next ) °Block structured languages contain link to lexically enclosing frame. High Mem Low Mem 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS寄存器使用情况的软件约定 0 zero constant 0 1 at reserved for assembler 2 v0 expression evaluation & 3 v1 function results 4 a0 arguments 5 a1 6 a2 7 a3 8 t0 temporary: caller saves . . . (callee can clobber) 15 t7 16 s0 callee saves . . . (caller can clobber) 23 s7 24 t8 temporary (caller saves) 25 t9 26 k0 reserved for OS kernel 27 k1 28 gp Pointer to global area 29 sp Stack pointer 30 fp frame pointer 31 ra Return Address (HW) 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS / GCC 调用约定 FP SPfact: addiu $sp, $sp, -32 sw $ra, 20($sp) sw $fp, 16($sp) addiu $fp, $sp, 32 . . . sw $a0, 0($fp) ... lw $31, 20($sp) lw $fp, 16($sp) addiu $sp, $sp, 32 jr $31 ra old FP ra old FP ra FP SP ra FP SP low address 前四个参数通过寄存器传送 北京大学计算机科学技术系 北京大学微处理器研究开发中心 C示例: swap swap(int v[], int k) { int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; } °假设swap被作为过程进行调用 °假设temp在寄存器 $15; 参数分别在 $a1, $a2; $16 是中间使用的寄存器( scratch reg): MIPS代码? 北京大学计算机科学技术系 北京大学微处理器研究开发中心 swap: MIPS swap: addi $sp,$sp, -4 ; create space on stack sw $16, 0($sp) ;callee saved register put onto stack sll $t2, $a2,2 ; mulitply k by 4 addu $t2, $a1,$t2 ; address of v[k] lw $15, 0($t2) ; load v[k] lw $16, 4($t2) ; load v[k+1] sw $16, 0($t2) ; store v[k+1] into v[k] sw $15, 4($t2) ; store old value of v[k] into v[k+1] lw $16, 8($sp) ; callee saved register restored from stack addi $sp,$sp, 4 ; restore top of stack jr $31 ; return to place that called swap 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Branch & Pipelines execute Branch Delay Slot Branch Target By the end of Branch instruction, the CPU knows whether or not the branch will take place. However, it will have fetched the next instruction by then, regardless of whether or not a branch will be taken. Why not execute it? ifetch execute ifetch execute ifetch execute LL: slt r1, r3, r5 li r3, #7 sub r4, r4, 1 bz r4, LL addi r5, r3, 1 Time ifetch execute 北京大学计算机科学技术系 北京大学微处理器研究开发中心 Filling Delayed Branches Inst Fetch Dcd & Op Fetch ExecuteBranch: Inst Fetch Dcd & Op Fetch Inst Fetch Executeexecute successor even if branch taken! Then branch target or continue Single delay slot impacts the critical path •Compiler can fill a single delay slot with a useful instruction 50% of the time. • try to move down from above jump •move up from target, if safe add r3, r1, r2 sub r4, r4, 1 bz r4, LL NOP ... LL: add rd, ... Is this violating the ISA abstraction? 北京大学计算机科学技术系 北京大学微处理器研究开发中心 转移 & 流水线 ifetch read compute write ifetch read compute write ifetch read compute write Bnch Delay Slot Branch Target 在转移指令的“READ”段的最后, CPU才知道转移是否真的发生。 然而,在上例中, 无论这个转移是否真的发生,它都将访取下一条指令。 北京大学计算机科学技术系 北京大学微处理器研究开发中心 延迟转移(Delayed Branches): 重新定义操作行为 Inst Fetch Dcd & Op Fetch ExecuteBranch: Inst Fetch Dcd & Op Fetch Inst Fetch Executeexecute successor even if branch taken! Then branch target or continue Single delay slot impacts the critical path • 在50%的时间,编译器能够移动一条有效指令 填充延迟槽。 •试图从跳转之前,移动下来指令 • 如果安全,可以从目标出移动来指令 add r3, r1, r2 sub r4, r4, 1 bz r4, LL ... LL: add rd, ... 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS 的其他指令 °break A breakpoint trap occurs, transfers control to exception handler °syscall A system trap occurs, transfers control to exception handler °coprocessor instrs. Support for floating point: discussed later °TLB instructions Support for virtual memory: discussed later °restore from exception Restores previous interrupt mask & kernel/user mode bits into status register °load word left/right Supports misaligned word loads °store word left/right Supports misaligned word stores 北京大学计算机科学技术系 北京大学微处理器研究开发中心 MIPS 指令系统的细节信息 °#0寄存器总是具有数值0 (即使试图对它写入其他数值,也是如此) °转移和跳转指令将返回地址PC+4装入链接寄存器( link register) °所有指令改变目标寄存器的所有 32 位信息 (包括lui, lb, lh),并读取源寄存器 的所有32位信息 (add, sub, and, or, 等等) °立即数算术和逻辑指令进行如下扩展: • 逻辑立即数(logical immediates) 零扩展到 32位 • 算术立即数(arithmetic immediates)符号扩展到32位 °指令lb 和 lh 装入的数据进行如下扩展: • lbu, lhu 是零扩展 • lb, lh 是符号扩展 °下面的算术和逻辑指令可能会出现溢出: • add, sub, addi • 以下指令不会出现溢出: addu, subu, addiu, and, or, xor, nor, shifts, mult, multu, div, divu 北京大学计算机科学技术系 北京大学微处理器研究开发中心 °Design alternative: • provide more powerful operations • goal is to reduce number of instructions executed • danger is a slower cycle time and/or a higher CPI °Sometimes referred to as RISC vs. CISC • virtually all new instruction sets since 1982 have been RISC • VAX: minimize code size, make assembly language easy instructions from 1 to 54 bytes long! °We will look at PowerPC and 80x86 Alternative Architectures 北京大学计算机科学技术系 北京大学微处理器研究开发中心 PowerPC °Indexed addressing • ex
本文档为【MIPS体系结构(北大课件)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_002755
暂无简介~
格式:pdf
大小:274KB
软件:PDF阅读器
页数:16
分类:互联网
上传时间:2013-03-15
浏览量:86