L09-ac-mips-proc2-logical-machine1

L09-ac-mips-proc2-logical-machine1 -...

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

View Full Document Right Arrow Icon
CS61C L9 (1) Chae, Summer 2008 © UCB Albert Chae, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #9 – MIPS Procedures II, Logical & Shift Ops, and Instruction Representation I 2008-7-7
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS61C L9 (2) Chae, Summer 2008 © UCB Revie w Functions called with jal , return with jr $ra . The stack is your friend: Use it to save anything you need. Just be sure to leave it the way you found it. Instructions we know so far Arithmetic: add, addi, sub, addu, addiu, subu Memory: lw, sw, lb, sb, lbu Decision: beq, bne, slt, slti, sltu, sltiu Unconditional Branches (Jumps): j, jal, jr Registers we know so far All of them! There are CONVENTIONS when calling procedures!
Background image of page 2
CS61C L9 (3) Chae, Summer 2008 © UCB Register Conventions (1/4) Calle R : the calling function Calle E : the function being called When callee returns from executing, the caller needs to know which registers may have changed and which are guaranteed to be unchanged. Register Conventions : A set of generally accepted rules as to which registers will be unchanged after a procedure call ( jal ) and which may be changed.
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS61C L9 (4) Chae, Summer 2008 © UCB Register Conventions (2/4) - saved $0 : No Change . Always 0. $s0 - $s7 : Restore if you change . Very important, that’s why they’re called saved registers. If the callee changes these in any way, it must restore the original values before returning. $sp : Restore if you change . The stack pointer must point to the same place before and after the jal call, or else the caller won’t be able to restore values from the stack. HINT -- All saved registers start with S !
Background image of page 4
CS61C L9 (5) Chae, Summer 2008 © UCB Register Conventions (3/4) - volatile $ra : Can Change . The jal call itself will change this register. Caller needs to save on stack if nested call. $v0 - $v1 : Can Change . These will contain the new returned values. $a0 - $a3 : Can change . These are volatile argument registers. Caller needs to save if they’ll need them after the call. $t0 - $t9 : Can change . That’s why they’re called temporary: any procedure may change them at any time. Caller needs to save if they’ll need them afterwards.
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS61C L9 (6) Chae, Summer 2008 © UCB Register Conventions (4/4) What do these conventions mean?
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/06/2009 for the course CS cs61c taught by Professor Cory during the Summer '08 term at Berkeley College.

Page1 / 43

L09-ac-mips-proc2-logical-machine1 -...

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

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