CS33-8

CS33-8 - MIPS Subprograms and Stack 9/2008 John A. Rohr CS...

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

View Full Document Right Arrow Icon
CS 33: Computer Organization Topic 8: MIPS Subprograms and Stack 9/2008 John A. Rohr All Rights Reserved JAR 8-1 MIPS Subprograms and 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
CS 33: Computer Organization Topic 8: MIPS Subprograms and Stack 9/2008 John A. Rohr All Rights Reserved JAR 8-2 Subprogram Communication Subprogram calls require conventions Established by computer designers Include hardware and software support Conventions facilitate communication Same conventions for all programmers Allow separately written program modules Integrate all parts of subprogram call/return
Background image of page 2
CS 33: Computer Organization Topic 8: MIPS Subprograms and Stack 9/2008 John A. Rohr All Rights Reserved JAR 8-3 Communication Elements Subprogram call Return address Return values Arguments Local data Register save area
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS 33: Computer Organization Topic 8: MIPS Subprograms and Stack 9/2008 John A. Rohr All Rights Reserved JAR 8-4 MIPS Subprogram Call Uses link instructions jal Jump and Link: Most commonly used! jalr Jump and Link Register bltzal Branch if Less Than Zero and Link bgezal Branch if Greater Than or Equal To Zero and Link Hardware sets up return address Automatically puts return address in ra
Background image of page 4
CS 33: Computer Organization Topic 8: MIPS Subprograms and Stack 9/2008 John A. Rohr All Rights Reserved JAR 8-5 MIPS Return Address Automatically stored by hardware Points to next instruction after call Stored in register ra by subprogram call instruction
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS 33: Computer Organization Topic 8: MIPS Subprograms and Stack 9/2008 John A. Rohr All Rights Reserved JAR 8-6 MIPS Return Values Registers defined by software conventions Two registers provided for values v0 v1 Can also use reference parameters
Background image of page 6
CS 33: Computer Organization Topic 8: MIPS Subprograms and Stack 9/2008 John A. Rohr All Rights Reserved JAR 8-7 MIPS Arguments Placed by software conventions First four arguments in registers a0 a1 a2 a3 Additional arguments in stack
Background image of page 7

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

View Full DocumentRight Arrow Icon
CS 33: Computer Organization Topic 8: MIPS Subprograms and Stack 9/2008 John A. Rohr All Rights Reserved JAR 8-8 MIPS Local Data Placed by software conventions Statically allocated on subprogram call Stored in stack Space released on subprogram return
Background image of page 8
CS 33: Computer Organization Topic 8: MIPS Subprograms and Stack 9/2008 John A. Rohr All Rights Reserved JAR 8-9 MIPS Register Save Area Placed by software conventions Statically allocated Stored in stack Two special registers Return Address: Return point in caller Frame Pointer: Base of stack frame Two register regions Caller saved registers Callee saved registers
Background image of page 9

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

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

This note was uploaded on 07/20/2009 for the course CS 33 taught by Professor Rohr during the Fall '08 term at UCLA.

Page1 / 31

CS33-8 - MIPS Subprograms and Stack 9/2008 John A. Rohr CS...

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

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