Question

In: Computer Science

MIPS a) Consider the C statement: a = (b + d) + (b - c) +...

MIPS

a) Consider the C statement: a = (b + d) + (b - c) + (c + d)

Which of the following assembly instructions can be used to replicate all or part of this statement in MIPS, without changing or reducing the equation. Assume variables a, b, c, and d are assigned to registers $s0, $s1, $s2 and $s3 respectively.

1. sub $t0, $s2, $s3

2. sub $t0, $s0, $s3

3. sub $t1, $s1, $s2

4. sub $t2, $s1, $s3

5. add $t2, $s0, $s3

6. add $t0, $s2, $s3

b) Consider the MIPS instruction: add $t0, $s0, $s1. What would the corresponding machine code be? Write your answer in binary, or in hexadecimal with no spaces.

c) Consider the machine code: 1000 1110 0000 1000 0000 0000 0000 0100. What MIPS instruction does this represent?

    1. lw $t0, 4($s0)

    2. sw $t6, 100($s3)

    3. add $t0, $t1, $t2

    4. beq $t7, $t8, 68

Solutions

Expert Solution

a) a b c d are assigned to register $s0 $1 $2 $3 respectively

Given a = (b+d) + (b-c) +(c+d)

As in the question it is mentioned that we are not allowed to change or reduce the equation (statement)

1.(c+d) can be calculated using 6. add $t0, $s2, $s3

2.(b-c) can be calculated using 3. sub $t1, $s1, $s2

3.(b+d) can be calculated using add $t2, $s1, $s3 (not present in given 6 statements)

adding and storing content of $t0 $t1 $t2 we can get desired equation

b) add $t0, $s0, $s1  

given instruction is register instruction

Register Instruction Format

Opcode Source 1 Source 2 Destination Shift Amount Function
000000 5 bits 5 bits 5 bits 5 bits 6 bits
 000000 10000 10001 01000 00000 100000   (answer)
  RI      $s0      $s1    $t0  unused   add

RI = register instruction

c) as all the option are having different instruction so just by looking opcode ie we can decide

100011 is opcode (first 6 bit ) which is opcode for load instruction.

so answer is option1  lw $t0, 4($s0)


Related Solutions

Write a MIPS program that executes the statement: s = (a + b) – (c +...
Write a MIPS program that executes the statement: s = (a + b) – (c + 101), where a, b, and c are user provided integer inputs, and s is computed and printed as an output. Answer the following: a. Suppose the user enters a = 5, b = 10, and c = -30, what is the expected value of s? b. Which instruction in your program computed the value of s and which register is used? c. What is...
Consider the cross: A/a; b/b; C/c; D/d; E/e x A/a; B/b; c/c; D/d; e/e a) what...
Consider the cross: A/a; b/b; C/c; D/d; E/e x A/a; B/b; c/c; D/d; e/e a) what proportion of the progeny will phenotypically resemble the first parent? b) what proportion of the progeny will genotypically resemble neither parent?
Consider the following propositional formula: (((A ^ B) -> C) ^ ((A ^ C) -> D))...
Consider the following propositional formula: (((A ^ B) -> C) ^ ((A ^ C) -> D)) -> ((A ^ B) -> D) Perform the following tasks for this formula: Convert this formula into CNF form and write a numbered list of all clauses obtained from this formula.
Consider mutually independent events: A, B, C and D. Prove that AnB (A intersection B) is...
Consider mutually independent events: A, B, C and D. Prove that AnB (A intersection B) is independent to CUD (C union D).
In the diagram, which point is at the lowest potential? (a) A (b) B (c) C (d) D
In the diagram, which point is at the lowest potential?(a) A(b) B(c) C(d) D
Find the value of a : b : c : d, if a : b = 2 : 3, b : c = 4 : 5 and c : d = 6 : 7.
Find the value of a : b : c : d, if a : b = 2 : 3, b : c = 4 : 5 and c : d = 6 : 7.
Consider a project consisting of four activities A, B, C, and D. The following are constraints...
Consider a project consisting of four activities A, B, C, and D. The following are constraints within which the project has to be conducted • A and B, the first activities of the project, can be started simultaneously. • C can be started only after A is completed. • D can be started only after B is completed Suppose the activity times for the activities are A = 4 weeks, B = 3 weeks, C = 2 weeks, D =...
Consider the following reaction at 309 K. 1 A + 1 B → C + D...
Consider the following reaction at 309 K. 1 A + 1 B → C + D where rate = rate=k[A]2[B]. An experiment was performed for a certain number of seconds where [A]o = 1.07 M and [B]o = 0.000167 M. A plot of ln[B] vs time had a slope of -9.63. What will the rate of this reaction be if a new experiment is preformed when [A] = [B] = 0.212 M?
In BitTorrent, consider peer A is connected to peers B, C, D and E. A asks...
In BitTorrent, consider peer A is connected to peers B, C, D and E. A asks the other peers for list of chunks that they have. B, C, D and E have the following chunks that are missing to A: B – C1, C3 C – C1, C3, C5 D – C3, C4, C5 E – C2, C4 Which is the chunk that A requests first, and from which peer?
We consider a GSP auction with four bidders, A, B, C and D. Since there are...
We consider a GSP auction with four bidders, A, B, C and D. Since there are four bidders only the three highest bidders will be displayed). The click frequency of the first, second and third positions are 100 clicks/hour, 75 clicks/hour and 35 clicks/hour, respectively. Bidders’valuation per click are vA = 10, vB = 6, vC = 4, vD = 3. Bidder B, C and D bid 5, 3 and 1, respectively. What is the optimal bid for A?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT