spring elec 5200 0016200 001 lecture 4 11 register fp

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: ame Pointer) $fp Procedure frame $sp Old procedure frame $fp Procedure frame $sp Dynamic data heap $gp Static data Dynamic data heap $gp Static data Machine code (text) pc Machine code (text) pc Reserved 0 Spring 2014, Feb 10 . . . Spring Reserved 0 ELEC 5200-001/6200-001 Lecture 4 12 Compiling a Procedure Call Consider a program that uses register $t0 and calls a Consider procedure proc proc Assembly code of program with procedure call: . . addi $sp, $sp, - 4 # adjust stack pointer $sp, adjust sw $t0, 0($sp) # save $t0 jal proc # call proc call proc lw $t0, 0($sp) # restore $t0 addi $sp, $sp, 4 # pop 1 word off stack . . Spring 2014, Feb 10 . . . Spring ELEC 5200-001/6200-001 Lecture 4 13 Compiling a Procedure Consider a procedure proc that uses register $s0 Consider proc Assembly code: proc : proc addi $sp, $sp, - 4 # adjust stack pointer $sp, adjust sw $s0, 0($sp) # save $s0 . Assembly code of proc Assembly proc . lw $s0, 0($sp) # restore $s0 addi $sp, $sp, 4 # pop 1 word off stack jr $ra # retur...
View Full Document

This document was uploaded on 02/23/2014 for the course COMUPER AR 6200 at Auburn University.

Ask a homework question - tutors are online