lec04_Mips_Subroutine_Calls

lec04_Mips_Subroutine_Calls - Lecture 4: MIPS Subroutines...

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

View Full Document Right Arrow Icon
Lecture 4: MIPS Subroutines and x86 Architecture Computer Architecture Csc 205
Background image of page 1

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

View Full DocumentRight Arrow Icon
MIPS Subroutine Calls When making a subroutine (procedure) call, it is necessary to Place inputs where they can be accessed by subroutine Transfer control to subroutine Peform the desired task Place the result value(s) where the calling program can access it Return control to the point of origin The subroutine caller or callee should save and restore registers used by the subroutine MIPS Provides instructions to assist in subroutine calls (jal) and returns (jr) Uses software conventions to » place subroutine input and output values » control which registers are saved/restored by caller and callee Uses a software stack to save/restore values
Background image of page 2
Subroutine Calls A: CALL B CALL C C: RET RET B: A A B A B C A B A Some machines provide a memory stack as part of the architecture (e.g., VAX) Sometimes stacks are implemented via software convention (e.g., MIPS)
Background image of page 3

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

View Full DocumentRight Arrow Icon
0 zero constant 0 1 at reserved for assembler 2 v0 3 v1 function results 4 a0 arguments 5 a1 6 a2 7 a3 8 t0 temporary: caller saves . . . (callee can clobber) 15 t7 MIPS: Software conventions for registers 16 s0 callee saves . . . 23 s7 24 t8 temporary (cont’d) 25 t9 26 k0 reserved for OS kernel 27 k1 28 gp Pointer to global area 29 sp stack pointer 30 fp frame pointer 31 ra Return Address (HW)
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

lec04_Mips_Subroutine_Calls - Lecture 4: MIPS Subroutines...

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

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