230Quiz3Notes

230Quiz3Notes - CSE/EEE230 Fall 2009 Quiz 3 Notes...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: CSE/EEE230 Fall 2009 Quiz 3 Notes Reference: Lecture Notes for Computer Organization and Design, 4 th Edition, 2009. For this portion of the class, you are responsible for the following sections in Chapter 2 of the text. 8 9 10 13 14 Sections not listed are optional and you are not responsible for the content. CSE/EEE230 Fall 2009 Quiz 3 Notes 2 What do we need to know? How to call a procedure return from call access global variables pass parameters return values preserve state of processor from call to call 3 2.8 Supporting Procedures in Computer Hardware CSE/EEE230 Fall 2009 Quiz 3 Notes In a high level program, to call a function (such as print) print (); Execution is transferred to function start When function is completed, execution returns to place where it was called 4 CSE/EEE230 Fall 2009 Quiz 3 Notes What needs to be done load PC with start of function code save address of next instruction for return location  need to keep track of where we are returning instruction to call function: jal jump and link instruction saves PC+4 in $ra  $ra (register 31) reserved for return address Use jal, not j j is a go-to a new address in the code jal is a call to a function 5 CSE/EEE230 Fall 2009 Quiz 3 Notes jal funct1 next1: jal funct2 next2: andi $t0, $t0, 0 6 call call return location return location CSE/EEE230 Fall 2009 Quiz 3 Notes A function is located at 0x40000800. If jal instruction to call the function is at address 0x40000620, what values are set into PC and $ra when the jal instruction is executed? 7 CSE/EEE230 Fall 2009 Quiz 3 Notes In high level language, return from a function occurs two ways Reaching end of function Explicit return statement void print () { cout << hello world\n; return; # not needed } 8 CSE/EEE230 Fall 2009 Quiz 3 Notes Remember on the call $ra is given the value of the return address So to return from the function, jr $ra Instructions work as pair jal call function jr return from function Must be used together for a correct call and return from function. 9 CSE/EEE230 Fall 2009 Quiz 3 Notes Function starts with label Function ends with jr instruction print: li $v0, 1 # command to print integer syscall # print value in $a0 jr $ra 10 CSE/EEE230 Fall 2009 Quiz 3 Notes jal funct1 or $t0, $t0, $t0 ......
View Full Document

Page1 / 81

230Quiz3Notes - CSE/EEE230 Fall 2009 Quiz 3 Notes...

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

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