mips-assembly-details

mips-assembly-details - CSE 341 MIPS Assembly Language...

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

View Full Document Right Arrow Icon
CSE 341 MIPS Assembly Language Using Procedures Steps Store parameters so they can be accessed by procedure Transfer control to procedure Perform task Store result for calling program Return to point of origin Register Allocation Arguments (a0-a3) Parameter passing Return values (v0-v1) Return address (ra) jal Address Automatically stores return address in return address register Program counter (pc) Stores address of instruction currently executing jal stores PC + 4 jr $ra Can be used to return from procedure Temporary Registers (t0 - t9) NOT preserved by callee Saved Registers (s0 - s7) Preserved by callee Register spilling Saving registers to stack Stack What is the stack? Last-in-first-out queue Stack grows from higher to lower addresses Stack pointer (sp) Stores pointer to top of stack Pop Removing data from stack Push Adding data to stack Don’t forget to adjust stack pointer when performing operations on 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
Leaf Routines Leaf Routine A procedure that does NOT call another routine Nested Procedures Caller Arguments (a0-a3) Temporary (t0-t9) Callee Return address register (ra) Saved registers (s0-s7) Why not save return value registers (v0-v1)? Using Procedures
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

mips-assembly-details - CSE 341 MIPS Assembly Language...

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

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