06_procedures

06_procedures - Procedures Procedure Execution procedure...

Info iconThis preview shows pages 1–2. 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 DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/17/2011 for the course CS M151B taught by Professor Tamir during the Summer '11 term at UCLA.

Page1 / 5

06_procedures - Procedures Procedure Execution procedure...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online