25.12.2012 Views

MIPS Assembly Language Programming

MIPS Assembly Language Programming

MIPS Assembly Language Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3<br />

Advanced <strong>MIPS</strong> Tutorial<br />

by Daniel J. Ellard<br />

This chapter continues the tutorial for <strong>MIPS</strong> assembly language programming and<br />

the SPIM environment 1 . This chapter introduces more advanced topics, such as<br />

how functions and advanced data structures can be implemented in <strong>MIPS</strong> assembly<br />

language.<br />

3.1 Function Environments and Linkage<br />

One of the most important benefits of a high-level language such as C is the notion<br />

of a function. In C, a function provides several useful abstractions:<br />

• The mapping of actual parameters to formal parameters.<br />

• Allocation and initialization of temporary local storage. This is particularly<br />

important in languages which allow recursion: each call to the function must<br />

get its own copy of any local variables, to prevent one call to a recursive function<br />

from clobbering the values of a surrounding call to the same function.<br />

1 For more detailed information about the <strong>MIPS</strong> instruction set and the SPIM environment, consult<br />

chapter 4 of this book, and SPIM S20: A <strong>MIPS</strong> R2000 Simulator by James Larus. Other<br />

references include Computer Organization and Design, by David Patterson and John Hennessy<br />

(which includes an expanded version of James Larus’ SPIM documentation as appendix A), and<br />

<strong>MIPS</strong> R2000 RISC Architecture by Gerry Kane.<br />

43

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!