Machine Organization and Assembly Language programming
Problem Set #2 Due: Wednesday April 16th
- 1. By the due date, you should have read Chapter 1,
Chapter 4 (Sections 4.1 to 4.3),
Chapter 3 (don't spend too much time on Section 3.12),
and Appendix A1, A2, A6, A9, A10 (not every line
of the latter; this is SPIM's ``reference manual'').
- 2. In Chapter 3, do:
- 3.1 Give the answer as a function of n.
- 3.6 You are encouraged to use SPIM to find the errors. In fact,
the PC version of SPIM will ``self-correct'' some of the errors.
- 3.10 Here again, use SPIM. Some versions of SPIM won't allow
some of the pseudoinstructions. Document the ones you find.
- After reading the ``Compact Code and Stack Architectures''
section pages 192-193 and the ``In More Depth'' pages 201-202,
do Exercise 3.19 only for the stack architecture.
A future programming assignment will be based on the stack architecture
concept so this exercise is important.
- Programming in SPIM. Exercise 3.22. Not only should the resulting
value be in $v0 but is should also be displayed on the SPIM console.
- Programming in SPIM.
Write a procedure in MIPS assembly language that finds
the number of elements strictly greater than the last element
and the number of even elements
in an array of integers (each element is a 32-bit positive, negative,
or null integer).
Your procedure will take two arguments: a pointer to the array of
integers that will be passed in register $a0 and the number of elements in
the array that will be passed in register $a1. Your procedure will return
the number of elements strictly greater than the last element in $vo
and the number of even elements in $v1.
Both of these values should be printed on the console.
You should design your own test files for the programming
assignments but you won't have to turn them in.
We'll have our own!
A good template for SPIM programs can be found at:
http://www.cs.washington.edu/education/courses/378/03sp/handouts/template.spim
Instructions for Turnin for the SPIM programming will be given
to you shortly.