011-05-19 011 年前学期 TOKYO TECH 命令処理のための基本的な 5 つのステップ 計算機アーキテクチャ第一 (E) 5. プロセッサの動作原理と議論 吉瀬謙二計算工学専攻 kise_at_cs.titech.ac.jp W61 講義室木曜日 13:0-1:50 IF(Instruction Fetch) メモリから命令をフェッチする. ID(Instruction Decode) 命令をデコード ( 解読 ) しながら, レジスタの値を読み出す. EX(Execution) 命令操作の実行またはアドレスの生成を行う. MEM(Memory Access) 必要であれば, データ メモリ中のオペランドにアクセスする. WB(Write Back) 必要であれば, 結果をレジスタに書き込む. 主な構成要素 (1) レジスタ マルチプレクサ ALU (Arithmetic Logic Unit) レジスタファイル読み出しポート, 書き込みポート 1 命令メモリ データメモリ 加算器 3 Machine Language - Add Instruction 0x800 add $t0, $s1, $s [ add $8, $17, $18 ] Instructions, like registers and ords of data, are bits long Arithmetic Instruction Format (R format): add $t0, $s1, $s 5 op 6-bits opcode that specifies the operation rs 5-bits register file address of the first source operand rt 5-bits register file address of the second source operand rd 5-bits register file address of the result s destination shamt 5-bits shift amount (for shift instructions) funct 6-bits function code augmenting the opcode Adapted from Computer Organization and Design, Patterson & Hennessy, 005 6 1
主な構成要素 () IR[5:1] IR[0:16] IR[15:11] 0x800 add $t0, $s1, $s [ add $8, $17, $18 ] 符号拡張 ビット左にシフト Instruction Decode & register file access Instruction Fetch Execution Write Back 7 8 0x80 addi $t0, $t1, -1 [ addi $8, $9, -1 ] 0x808 l $t0, ($s) [ l $8, ($18) ] 9 10 0x80C s $t0, ($s) [ s $8, ($18) ] 0x810 beq $s0, $s1, Label [beq $16, $17, Label ] Label: 0x830 11 1
Exercise op rs rt 16 bit immediate 氏名, 学籍番号, 学籍番号マーク欄 ( 右詰で ) I format 0x810 beq $s0, $s1, Label [beq $16, $17, Label ] Label: 0x830 $s0 =5, $s1 = 5 今日の日付, 科目名 : Arch I Other Control Flo Instructions MIPS also has an unconditional branch instruction or jump instruction: j label #go to label Instruction Format (J Format): op 6-bit address from the lo order 6 bits of the jump instruction 6 ビットの命令列を 進数で示せ. この命令を実行する際, 確定するデータパスに値を示せ. 00 PC 13 1 非同期式メモリ 非同期式メモリ 15 Adapted from Computer Organization and Design, Patterson & Hennessy, 005 エッジトリガ方式による設計 プロセッサのデータパス ( マルチ サイクル ) State Element 1 Combinational logic State Element IF ID EX MEM WB Clock cycle 17 18 3
プロセッサのデータパス ( マルチ サイクル ) IF ID EX MEM WB 19 0 1 プロセッサの3つの実現方式 シングル サイクル マルチ サイクル パイプライン処理 オペランド数 3オペランド MIPS, オペランド SuperH ADD Rm, Rn : Rn <- Rn + Rm MIPS Arithmetic Instruction Format (R format): add $t0, $s1, $s 3
基本記憶方式 general-purpose register architecture stack architecture queue architecture accumulator architecture Discussion RISC (Reduced Instruction Set Computer) MIPS, SPARC CISC (Complex Instruction Set Computer) IA(Intel Architecture)- or x8086, stack queue accumulator push pop enqueue dequeue 5 6 IA- Registers and Data Addressing Registers in the -bit subset that originated ith 80386 Name Use 31 0 EAX GPR 0 ECX GPR 1 IA- Typical Instructions Four major types of integer instructions: Data movement including move, push, pop Arithmetic and logical (destination register or memory) Control flo (use of condition codes / flags ) String instructions, including string move and string compare EDX EBX ESP EBP ESI EDI GPR GPR 3 GPR GPR 5 GPR 6 GPR 7 CS SS DS ES FS GS Code segment pointer Stack segment pointer (top of stack) Data segment pointer 0 Data segment pointer 1 Data segment pointer Data segment pointer 3 EIP Instruction pointer (PC) EFLAGS Condition codes 7 8 IA- instruction Formats Typical formats: (notice the different lengths) a. JE EIP + displacement 8 JE b. CALL c. MOV EBX, [EDI + 5] MOV CALL Condition d d. PUSH ESI Displacement 8 6 1 1 8 8 5 3 r/m Postbyte Displacement Offset アナウンス 講義スライドおよびスケジュール.arch.cs.titech.ac.jp 講義日程が変更になることがあるので頻繁に確認すること. PUSH Reg e. ADD EAX, #6765 3 1 ADD Reg Immediate f. TEST EDX, # 7 1 8 TEST Postbyte Immediate 9 30 5