lect.05.Performance.4up

lect.05.Performance.4up - Announcements Upcoming deadlines...

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

View Full Document Right Arrow Icon
EE108b Lecture 5 C. Kozyrakis 1 EE108B – Lecture 5 CPU Performance Christos Kozyrakis Stanford University http://eeclass.stanford.edu/ee108b EE108b Lecture 5 C. Kozyrakis 2 Announcements • Upcoming deadlines – HW1 due on Tuesday 1/25 – Lab1 due on Tuesday 1/30 – PA1 due on Thursday 2/8 EE108b Lecture 5 C. Kozyrakis 3 Review: Procedure Call and Return Procedures are required for structured programming Aka: functions, methods, subroutines, … Implementing procedures in assembly requires several things to be done Memory space must be set aside for local variables Arguments must be passed in and return values passed out Execution must continue after the call Procedure Steps 1. Place parameters in a place where the procedure can access them 2. Transfer control to the procedure 3. Acquire the storage resources needed for the procedure 4. Perform the desired task 5. Place the result value in a place where the calling program can access it 6. Return control to the point of origin EE108b Lecture 5 C. Kozyrakis 4 Stacks • Data is pushed onto the stack to store it and popped from the stack when not longer needed – MIPS does not support in hardware (use loads/stores) – Procedure calling convention requires one • Calling convention – Common rules across procedures required – Recent machines are set by software convention and earlier machines by hardware instructions • Using Stacks – Stacks can grow up or down – Stack grows down in MIPS – Entire stack frame is pushed and popped, rather than single elements
Background image of page 1

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

View Full DocumentRight Arrow Icon
EE108b Lecture 5 C. Kozyrakis 5 Static data Dynamic data MIPS Storage Layout $sp = 7fffffff 16 10000000 16 Reserved Text/Code Stack Stack and dynamic area grow towards one another to maximize storage use before collision 400000 16 $gp = 10008000 16 EE108b Lecture 5 C. Kozyrakis 6 Procedure Activation Record (Frame) textbook • Each procedure creates an activation record on the stack Saved arguments Saved registers (if any) Local Arrays and Structures (if any) Saved return address $fp $sp Higher addresses Lower addresses Stack grows downwards First word of frame Last word of frame EE108b Lecture 5 C. Kozyrakis 7 Procedure Activation Record (Frame) SGI/GCC Compiler • Each procedure creates an activation record on the stack – At least 32 bytes by convention to allow for $a0-$a3, $ra, $fp and be double double word aligned (16 byte multiple) Arguments (>= 16 B) Space for nested call args (>= 16 B) Local Arrays and Structures (if any) Saved return address $fp $sp Higher addresses Lower addresses Stack grows downwards First word of frame Last word of frame Saved registers EE108b Lecture 5 C. Kozyrakis 8 Register Assignments • Use the following calling conventions Name Register number Usage $zero 0 the constant value 0 $v0-$v1 2-3 values for results and expression evaluation $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
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/08/2011 for the course EE 108B at Stanford.

Page1 / 12

lect.05.Performance.4up - Announcements Upcoming deadlines...

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

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