1 / 5

Procedure call frame: Hold values passed to a procedure as arguments Save registers

Procedure call frame: Hold values passed to a procedure as arguments Save registers Space for local variables. MIPS: Software conventions for Registers. 0 zero constant 0 1 at reserved for assembler 2 v0 expression evaluation & 3 v1 function results 4 a0 arguments 5 a1

ericav
Download Presentation

Procedure call frame: Hold values passed to a procedure as arguments Save registers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Procedure call frame: • Hold values passed to a • procedure as arguments • Save registers • Space for local variables

  2. MIPS: Software conventions for Registers 0 zero constant 0 1 at reserved for assembler 2 v0 expression evaluation & 3 v1 function results 4 a0arguments 5 a1 6 a2 7 a3 8 t0temporary: caller saves . . . 15 t7 16 s0callee saves . . . 23 s7 24 t8temporary (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

  3. Caller: • Pass arguments: • - First 4 in registers $a0 - $a3; • - Remaining pushed on the stack (at the beginning of the stack frame) • Save caller-saved registers ($a0-$a3, $t0, $t9). The callee can use these registers. • Execute jal • Callee (before starts running): • Allocate memory for the frame by subtracting the frame size from the stack pointer. • Save callee-saved registers in the frame ($s0-$s7, $fp, $ra) before altering them. • Establish the frame pointer by adding the frame size minus 4 to $sp and storing the sum in $fp. • Callee (before returning): • If it is a function, place the returned value in register $v0 • Restore the callee-save registers • Pop the stack frame by subtracting the frame size from $sp • Return by executing jr $ra

  4. MIPS Calling Conventions FP SP fact: subu $sp, $sp, 32 sw $ra, 20($sp) sw $fp, 16($sp) addu $fp, $sp, 32 sw $a0, 0($fp) ... lw $ra, 20($sp) lw $fp, 16($sp) addu $sp, $sp, 32 jr $ra ra FP SP ra ra old FP FP SP ra old FP First four arguments passed in registers.

More Related