HCL Operations a Classify by type of value returned Boolean Expressions ■ Logic Operations ●a&&b,al|b,! ■ Word com parisons OA == B,A != B,A< B,A<= B,A > B,A>B ■ Set Mem bership A in[ B, C,d 1 ) Same asA== B 二二 Word Expressions a Case expressions A b: B: C: C] O Evaluate test expressions a, b, C,.. in sequence o Return word expression A, B, C,. for first successful test Processor
– 6 – Processor HCL Operations ◼ Classify by type of value returned Boolean Expressions ◼ Logic Operations ⚫ a && b, a || b, !a ◼ Word Comparisons ⚫ A == B, A != B, A < B, A <= B, A >= B, A > B ◼ Set Membership ⚫ A in { B, C, D } » Same as A == B || A == C || A == D Word Expressions ◼ Case expressions ⚫ [ a : A; b : B; c : C ] ⚫ Evaluate test expressions a, b, c, … in sequence ⚫ Return word expression A, B, C, … for first successful test
43.1 Instruction Execution Stages P281 Fetch a Read instruction from instruction memory Decode a Read program registers Execute a Compute value or address Memory ■ Read or write data Write Back a Write program registers PC a Update program counter Processor
– 7 – Processor 4.3.1 Instruction Execution Stages P281 Fetch ◼ Read instruction from instruction memory Decode ◼ Read program registers Execute ◼ Compute value or address Memory ◼ Read or write data Write Back ◼ Write program registers PC ◼ Update program counter
Instruction Decoding Optional Optional 50rAIrB D icode ifun TA B valc Instruction Format ■ nstruction byte icode: ifun a Optional register byte rA: rB a Optional constant word valC 8 Processor
– 8 – Processor Instruction Decoding Instruction Format ◼ Instruction byte icode:ifun ◼ Optional register byte rA:rB ◼ Optional constant word valC 5 0 rA rB D icode ifun rA rB valC Optional Optional
Figure 4.16 P283 Executing Arith /Logical Operation OPl rA, rB 6 fn ralrB Fetch Memory Read 2 bytes Do nothing Decode Write back Read operand registers ■ Update register Execute PC Update ■ Perform operation ■ Increment Pc by2 Set condition codes -9 Processor
– 9 – Processor Figure 4.16 P283 Executing Arith./Logical Operation Fetch ◼ Read 2 bytes Decode ◼ Read operand registers Execute ◼ Perform operation ◼ Set condition codes Memory ◼ Do nothing Write back ◼ Update register PC Update ◼ Increment PC by 2 OPl rA, rB 6 fn rA rB
Stage Computation: Arith/Log. Ops P283 igure 4.16 OPl A, rB icode:ifun←-M1[Pc] Read instruction byte rA:rB←M1[Pc+们 Read register byte Fetch vaIP tPC+2 Compute next PC vaA←R[A Read operand a Decode vaB←R[rB] Read operand B vale t valB oP valA Perform ALU operation Execute Set cc Set condition code register Memory Write RrB]←vaE Write back result back PC update PC←vaP Update Pc a Formulate instruction execution as sequence of simple steps a Use same general form for all instructions 10-MPC]表示从PC开始的内存中读取一个字节的数据 Processor
– 10 – Processor Stage Computation: Arith/Log. Ops P283 Figure 4.16 ◼ Formulate instruction execution as sequence of simple steps ◼ Use same general form for all instructions OPl rA, rB icode:ifun M1 [PC] rA:rB M1 [PC+1] valP PC+2 Fetch Read instruction byte Read register byte Compute next PC valA R[rA] valB R[rB] Decode Read operand A Read operand B valE valB OP valA Set CC Execute Perform ALU operation Set condition code register Memory Write R[rB] valE back Write back result PC update PC valP Update PC M1 [PC] 表示从PC开始的内存中读取一个字节的数据