CS 2734
Computer Organization II
Lecture 4: Simple Sparc Programs (no logic)
- 1/24/97
Read Paul p. 43 - 48 (Sections 2.1 - 2.4)
- Review Sparc Registers (see the table on page 44 of Paul):
- g registers are the global registers.
- o registers are for passing parameters to called functions.
- l registers for local variables.
- i registers for incoming function arguments.
- Examples of simple Sparc instructions.
- add (Paul p. 358)
- sub (Paul p. 361)
- and (Paul p. 366)
- or (Paul p. 367)
- Parameter passing in registers (call by value):
- The calling program puts the values in %o0,
%o1, ... in order.
- The called function accesses these same values in
%i0, %i1, ...
This is what is meant by overlapping register windows.
- If you haven't already done so, download
the simple example
simplesparc.m and compile by making
Makefile.
- Parameter passing in the programs from laboratory 1:
- Passing a simple value (passvalue):
- Call by reference (passaddr):
- Returning a value (returnvalue):
SKILL: You should be able to write Sparc instructions
to evaluate a simple arithmetic expression.