Question

In: Computer Science

Assume that the variables w, x, y, and z are stored in memory locations 16, 32,...

Assume that the variables w, x, y, and z are stored in memory locations 16, 32, 48, and 128 respectively. Translate the following algorithmic operations into MIPS language equivalents:

[Assume $s1 is the base register, and $s1 contains the address of memory location 0]

                                                                                                           

if ((x – y) ³ w) then

      set x to y

else:

set x to z

endif

Solutions

Expert Solution

C code
if ((x – y)³ < w) then
   set x to y
else:
   set x to z
endif

MIPS Code

   lw $t1, 16($s1)       //$t1 = w
   lw $t2, 32($s1)       //$t2 = x
   lw $t3, 48($s1)       //$t3 = y

   sub $t2, $t2, $t3   //$t2 = (x-y)
   mult $t2, $t2
   mfhi $t4       //$t4 = (x-y)^2
   mult $t4, $t2
   mfhi $t4       //$t4 = (x-y)^3

   slt $t2, $t4, $t1   //if((x-y)^3 < w) $t2 = 1
   beq $t2, $zero, Else   //if($t2 = 0) Branch to Else
   sw $t3, 32($s1)       // x = y

Else:
   lw $t3, 128($s1)   //$t3 = z
   sw $t3, 32($s1)       // x = z


Related Solutions

Please explain this prolog code line by line. union([X|Y],Z,W) :- member(X,Z), union(Y,Z,W). union([X|Y],Z,[X|W]) :- \+ member(X,Z),...
Please explain this prolog code line by line. union([X|Y],Z,W) :- member(X,Z), union(Y,Z,W). union([X|Y],Z,[X|W]) :- \+ member(X,Z), union(Y,Z,W). union([],Z,Z).
x, y, z, w, u and t are integer variables, what will their value be after...
x, y, z, w, u and t are integer variables, what will their value be after the execution of the statements below. Give the final value of each variable x = 7; y = x + 1; z = x % (y – 2) + 4; y = (y + z ) % (x + 4) ; w = (x * y) / (z – 3); x = x + x; u = w - 3; t = z +...
Assume that X, Y, and Z are independent random variables and that each of the random...
Assume that X, Y, and Z are independent random variables and that each of the random variables have a mean of 1. Further, assume σX = 1, σY = 2, and σZ = 3. Find the mean and standard deviation of the following random variables: a. U = X + Y + Z b. R = (X + Y + Z)/3 c. T = 2·X + 5·Y d. What is the correlation between X and Y? e. What is the...
Assume the following preference order for four goods, w, x, y, and z, of a total...
Assume the following preference order for four goods, w, x, y, and z, of a total of 26 people: # of people 9 6 2 4 5 W X Y Y Z Z Y X Z X X Z Z X Y Y W W W W You want to extract the will of the group and employ different rules. What is the group's preference order when you employ: A) Plurality Vote B) Condorcet Vote C) Borda Count D) "Vote...
The following logic function is given as a sum of minterms F(W,X,Y,Z) = ∑W,X,Y,Z(7,8,10,11,13) + D(5,...
The following logic function is given as a sum of minterms F(W,X,Y,Z) = ∑W,X,Y,Z(7,8,10,11,13) + D(5, 9, 15). (25 points) a) Draw the K-Map and find the minimal sum-of-products expression for this function. b) Draw the circuit implementing this expression c) Give all input pair or pairs where transition between them would create a timing hazard d) Draw the timing diagram showing the glitch corresponding to the pair or one of the pairs. Assume ALL gate delays are equal e)...
a.Consider a hypothetical gas of four distinguishable particles, labeled W, X, Y and Z. Assume that...
a.Consider a hypothetical gas of four distinguishable particles, labeled W, X, Y and Z. Assume that they are distributed between only two translational quantum states of energies 2E and 4E. How many different configurations of this gas are there? b.Consider a hypothetical gas of three distinguishable particles, labeled A, B and C. Each of the particles has only three quantum states of energies 5E, 10E and 15E. How many different configurations of this gas have a total energy of 30E?...
The joint density function for random variables X, Y, and Z is f(x, y, z)= Cxyz  if...
The joint density function for random variables X, Y, and Z is f(x, y, z)= Cxyz  if 0 ≤ x ≤ 1, 0 ≤ y ≤ 2, 0 ≤ z ≤ 2, and f(x, y, z) = 0 otherwise. (a) Find the value of the constant C. (b) Find P(X ≤ 1, Y ≤ 1, Z ≤ 1). (c) Find P(X + Y + Z ≤ 1).
1) Generate a data set with three variables (X, Y and Z). X and Y have...
1) Generate a data set with three variables (X, Y and Z). X and Y have 10 observations for each (N=10), and Z has 13 observations (N=13). Each observation should have two digits (such as “83” or “8.3”). 2) Draw a stem-and-leaf display for variable Z only and draw a box plot display for variable Z after specifying the 5 numbers (UEX, LEX, FU, FL, MD). 3) Calculate the mean and standard deviation for variable X 4) Calculate the mean...
[x, y, and z are integer variables, which expressions are equivalent to each other?] a. (x==y...
[x, y, and z are integer variables, which expressions are equivalent to each other?] a. (x==y && x !=z) || (x!=y && x==z) b. (x==y || x==z) && (x!=y || x!=z) c. (x==y) != (x==z)
Suppose x,y ∈ R and assume that x < y. Show that for all z ∈...
Suppose x,y ∈ R and assume that x < y. Show that for all z ∈ (x,y), there exists α ∈ (0,1) so that αx+(1−α)y = z. Now, also prove that a set X ⊆ R is convex if and only if the set X satisfies the property that for all x,y ∈ X, with x < y, for all z ∈ (x,y), z ∈ X.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT