{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

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

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-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
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
Image of page 3

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

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-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
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
Image of page 5

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

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-6 MIPS Return Values Registers defined by software conventions Two registers provided for values v0 v1 Can also use reference parameters
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
Image of page 7

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

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-8 MIPS Local Data Placed by software conventions Statically allocated on subprogram call Stored in stack Space released on subprogram return
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
Image of page 9

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern