CSE378 Fall 1998 Homework 4

CSE378 Fall 1998 Homework 4

DUE: Monday, October 26, by the start of class.

PROBLEM 1:

Implement a simple calculator in SPIM. Your calculator should expect infix notation to perform the following operations on integers:

It should maintain the result of the last calculation. If a sentence begins with the operator, rather than a number, use the result of the previous calculation as the first operand. Your calculator should continue to run until it reads the character 'q'.

Below is a sample of what running your completed code should look like:

> 4 + 5
9
> / 3
3
> 8 * 2
16
> q
Goodbye.

EXTRA CREDIT: For extra credit, implement your calculator to operate on double precision integers. If you do the extra credit, please indicate so in a comment at the top of your code file.

PROBLEM 2:

From the book, do problems 4.14, 4.18, 4.19, 4.24, and 4.31.

NOTE: Your work for these two problems should be submitted in two separate files. The code for problem 1 should be in a file named calc.s, and should be loadable into SPIM with no changes necessary. Your work for problem 2 can be handed in electronically, as another file (turnin will accept multiple files, or a directory containing multiple files) or on paper in class.