{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

06_procedures

06_procedures - Procedures Procedure Execution...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS151B 6.1 Procedures procedure (subroutine): code that can be invoked from several places in the program program procedure 1 1 2 2 advantages: • code space reduction • framework for sharing procedures • framework for modular programming • simplify recursive code disadvantages: overhead during execution 2011, Y. Tamir CS151B 6.2 Procedure Execution caller (calling routine/procedure): put arguments where callee can access them transfer (jump) to the callee callee (called routine): allocate storage needed by callee execute callee put return value where caller can access it transfer (jump) back to the caller overhead 2011, Y. Tamir CS151B 6.3 Requirements for Procedure Calls hardware: mechanism for obtaining the value of the PC 2011, Y. Tamir CS151B 6.4 Single Cycle MIPS Implementation Read register 1 Read register 2 Write register Write data Write data Registers ALU Add Zero Read data 1 Read data 2 Sign extend 16 32 Instruction [31–0] ALU result Add ALU result M u x M u x M u x Address Data memory Read data Shift left 2 4 Read address Instruction memory PC 1 0 0 1 0 1 M u x 0 1 ALU control Instruction [5–0] Instruction [25–21] Instruction [31–26] Instruction [15–11] Instruction [20–16] Instruction [15–0] RegDst Branch MemRead MemtoReg ALUOp MemWrite ALUSrc RegWrite Control 2011, Y. Tamir
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon