Question

In: Computer Science

Question: Consider the following C language instruction. A[10] = ((f+g) – (h+A[5])) + 100; Translate the...

Question:

Consider the following C language instruction.

A[10] = ((f+g) – (h+A[5])) + 100;

Translate the above code into MIPS assembly language code. Assume variables f, g, and h are associated

with registers $S0, $S1, and $S2 respectively. The base address of A is associated with register $S5.

Solutions

Expert Solution

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.

code snippet

copy to code

.text
#f is in $s0
#g is in $s1
#h is in $s2
#Base address of A is in $s5

#get f+g
add $t0,$s0,$s1

#get A[5] using 20, Because int is of 4 byte in size
#hence 5th element will be at 20th position
lw $t1,20($s5)

#get h+A[5]
add $t1,$t1,$s2

#get f+g - (h+A[5])
sub $t0,$t0,$t1

#get f+g - (h+A[5])+100
add $t0,$t0,100

#now store the result at location A[10]
sw $t0,40($s5)


Related Solutions

1.) Translate the following C code to MIPS assembly code. Assume that the variables f, g,...
1.) Translate the following C code to MIPS assembly code. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively   B[8] = A[i-j]; 2.Translate the following C code to MIPS assembly code. Assume that the values of v in $a0, k in $a1, temp in $t0.    // leaf procedure that...
Consider the relation R= {A, B, C, D, E, F, G, H} and the set of...
Consider the relation R= {A, B, C, D, E, F, G, H} and the set of functional dependencies: FD= {{B}—> {A}, {G}—> {D, H}, {C, H}—> {E}, {B, D}—> {F}, {D}—>{C}, {C}—> {G}} 1) Draw FD using the diagrammatic notation. 2) What are all candidate keys for R? 3) If delete {C}—>{G} and change {C, H}—> {E} to {C, H}—> {E, G}, what are all candidate keys for R
Consider the following bivariate data. Point A B C D E F G H I J...
Consider the following bivariate data. Point A B C D E F G H I J x 0 1 1 2 3 4 5 6 6 7 y 5 5 6 5 4 3 2 0 1 1 (a) Construct a scatter diagram of the given bivariate data. (Do this on paper. Your instructor may ask you to turn in this work.) (b) Calculate the covariance. (Give your answer correct to two decimal places.) (c) Calculate sx and sy. (Give...
Consider the following demand curve: A B C D E F G H I J P...
Consider the following demand curve: A B C D E F G H I J P $0.50 $0.45 $0.40 $0.35 $0.30 $0.25 $0.20 $0.15 $0.10 $0.05 QD 1 2 4 6 9 12 16 20 25 30 Calculate elasticities for pairs of points to check statements that were made during class and in the text. When making the calculations, use average price and average quantity for the two points. The formula for this should be in your notes. It is...
If f and g are both differentiable functions. If h = f g, then h'(2) is: ___________________
  If f and g are both differentiable functions. If h = f g, then h'(2) is: ___________________ Given the function: y=sin(4x)+e^-3x and dx/dt = 3 when x=0. Then dy/dt = ________________ when x=0. Let f(x) = ln (√x). The value of c in the interval (1,e) for which f(x) satisfies the Mean Value Theorem (i.e f'(c)= f(e)-f(1) / e-1 ) is: _________________________ Suppose f(x) is a piecewise function: f(x) = 3x^2 -11x-4, if x ≤ 4 and f(x) =...
Consider the following C code: (10 marks) // write a MIPS instruction to initialize s0 to...
Consider the following C code: // write a MIPS instruction to initialize s0 to 6 t0 = ((s03 - 93)2 + s0 ) << 2 t1 = t0 / 4 Q2.1: Write a MIPS program that performs the operation of the above C program. Q2.2: What is the value of $t0 and $t1 after running your MIPS program (write your answer in a comment at the end of the code). Submit your answer to Q2 in a file named A2_Q2.asm
(a) (f ∘ g)(3) (b) g(f(2)) (c) g(f(5)) (d) (f ∘ g)(−3) (e) (g ∘ f)(−1) (f) f(g(−1))
(a)    (f ∘ g)(3) (b)    g(f(2)) (c)    g(f(5)) (d)    (f ∘ g)(−3) (e)    (g ∘ f)(−1) (f)    f(g(−1))  
1. ¬B∨(G↔J), H→(B&C) ∴(H&J)→G 2. A∨B, C↔¬(B∨D) ∴C→A 3. (A&B) ↔ (F→G), (A&F) & B∴(G→R)→R 4....
1. ¬B∨(G↔J), H→(B&C) ∴(H&J)→G 2. A∨B, C↔¬(B∨D) ∴C→A 3. (A&B) ↔ (F→G), (A&F) & B∴(G→R)→R 4. T→¬B, T→¬D ∴ T→¬(B∨D) 5. ¬(M∨¬S), S→(R→M) ∴A → (¬R∨T) 6. (F&G) → I, (I∨J) → K ∴F→(G→K) 7. ¬U, O→G, ¬(O∨G) →U ∴G Prove that the arguments are valid by constructing a dedication using the rules MP, MT, DN, Conj, Simp, CS, Disj, DS, DM, CP, HS, BE, and DL. Use CP if needed.
Consider the following reaction which is at equilibrium at 100°C: A(g) + B(g) ↔ AB (g)...
Consider the following reaction which is at equilibrium at 100°C: A(g) + B(g) ↔ AB (g) ΔH=420 kJ/mol Predict the direction where the reaction would proceed, and explain your reasoning: a. The reaction vessel were pressurized to 5atm with helium b. The temperature were increased to 200°C c. The reaction were coupled with another reaction: AB + D2 → AD + BD d. The volume of the reaction vessel were increased from 2.0L to 5.0L without removing any gas e....
Here is the equation 2 C 4 H 10 (g)+13 O 2 (g)→10 H 2 O(g)+8C...
Here is the equation 2 C 4 H 10 (g)+13 O 2 (g)→10 H 2 O(g)+8C O 2 (g) Calculate the mass of water produced when 1.20 g of butane reacts with excess oxygen. Calculate the mass of butane needed to produce 68.0 g of carbon dioxide.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT