L11 - CS 61C Mike Clancy(substitute lecturer Topic MIPS...

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

View Full Document Right Arrow Icon
1 CS 61C, Sept 21, 2007 1 CS 61C Mike Clancy (substitute lecturer) September 21, 2007 Topic: MIPS procedures CS 61C, Sept 21, 2007 2 Components of MIPS procedure call/return • Linkage (how to call, how to return) • Communication via registers • Use of the stack
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 CS 61C, Sept 21, 2007 3 Call to/return from a very simple function # Caller does … jal lazyfunct # Callee does … lazyfunct: jr $ra “Jump And Link” puts the address of the immediately following instruction into $ra , then jumps to the given location “Jump Register” jumps to the address contained in the given register CS 61C, Sept 21, 2007 4 More on jal • “Jump And Link” should really be called “Link and Jump”. • Syntax is exactly the same as a j instruction. • Why have a jal? Function calling is very common.
Background image of page 2
CS 61C, Sept 21, 2007 5 Call to/return from a slightly less simple function # Caller does … lw $a0,valToSquare jal square # Callee does … square: mult $a0,$a0 # don’t worry about mflo $v0 # the details of this jr $ra CS 61C, Sept 21, 2007 6 Register use conventions (1) • Arguments get passed from caller to callee in $a0, $a1, $a2, $a3. • Return value gets passed from callee to caller
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/09/2008 for the course CS 61A taught by Professor Harvey during the Spring '08 term at Berkeley.

Page1 / 9

L11 - CS 61C Mike Clancy(substitute lecturer Topic MIPS...

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

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