CS 233 Study Guide - Midterm Guide: Register Allocation, Program Counter, Assembly Language

79 views6 pages
4 Apr 2016
Course
Professor

Document Summary

Invoking a function changes the control ow of a program twice: calling the function, returning from the function. In this example the main function calls fact twice, and fact returns twice, but to di erent locations in main. Each time fact is called, the cpu has to remember the appropriate return address. Notice that main itself is also a function! It is, in e ect, called by the operating system when you run the program. To transfer control back to the caller, the function just has to jump to the address that was stored in . The blue parts of the program show the actual and formal arguments of the fact function. The purple parts of the code deal with returning and using a result. Mips uses the following conventions for function arguments and results. Up to four function arguments can be passed by placing them in argument registers - before calling the function with jal.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents