# CS/EE 3810 Assignment 3 solved

\$35.00

Category:

## Description

doing; in one sentence, explain what this procedure is trying to accomplish. (15
points)
new-proc:
sll \$a0, \$a0, 24
srl \$a0, \$a0, 24
jr \$ra
doing; provide a simple equation to express the return value v0 as a function of input
arguments a0 and a1. (35 points)
new-proc:
blt \$a1, \$zero, loop2
loop1:
beq \$a1, \$zero, proc-end
sll \$a0, \$a0, 1
j loop1
loop2:
beq \$a1, \$zero, proc-end
srl \$a0, \$a0, 1
j loop2
proc-end:
jr \$ra
3. For the (pseudo) assembly code below, replace X, Y, P, and Q with the smallest set of
instructions to save/restore values on the stack and update the stack pointer. Assume
that procA and procB were written independently by two different programmers who
are following the MIPS guidelines for caller-saved and callee-saved registers. In other
words, the two programmers agree on the input arguments and return value of
procB, but they can’t see the code written by the other person. Be sure to read the
class notes first so you understand the MIPS guidelines for caller-saved and calleesaved registers. (50 points)
CS/EE 3810
http://www.cs.utah.edu/~rajeev/cs3810/hw/hw18-3.html 2/2
procA:
\$s0 = …
\$s1 = …
\$s2 = …
\$t0 = …
\$t1 = …
\$t2 = …
X
\$a0 = …
\$a1 = …
jal procB
Y
… = \$s1
… = \$t0
… = \$t1
… = \$a0
jr \$ra
procB:
P
… = \$a0
… = \$a1
\$s2 = …
\$t0 = …
Q
jr \$ra