Topic 4b - Procedures II

# Topic 4b - Procedures II - Computer Architecture...

This preview shows pages 1–8. Sign up to view the full content.

Computer  Architecture Procedures II Reading:  Section 2.13

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

View Full Document
A Glance at the Schedule What’s coming in… Lab2 – Today midnight Hw1 – Monday midnight What’s going out…
Outline  Procedure examples Recursive Non-recursive Work on relprime() Start thinking about designing an assembler

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

View Full Document
“A computer once beat me at chess, but it was  no match for me at kick boxing. . “
Leaf Procedure Example Doesn’t call another procedure C code: int leaf_example (int g, h,  i, j) int f;   f = (g + h) - (i + j);   return f; } Arguments g, …, j in \$a0, …, \$a3 f in \$s0 (hence, need to save \$s0 on stack) CAT #1

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

View Full Document
Leaf Procedure Example Assuming that \$T0 and \$T1  have to be saved MIPS code: leaf_example:   addi \$sp, \$sp, -4 sw \$s0, 0(\$sp) add  \$t0, \$a0, \$a1   add  \$t1, \$a2, \$a3   sub  \$s0, \$t0, \$t1   add  \$v0, \$s0, \$zero   lw   \$s0, 0(\$sp) addi \$sp, \$sp, 4
To Preserve or Not??

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

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

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern