Chapter 2: Q2E (page 164)
Question: For the following MIPS assembly instructions above, what is a corresponding C statement?
add f, g, h
add f, i, f
Short Answer
For instructions,
add f, g, h
add f, i, f corresponding C statement is :
f = i+g+h
Chapter 2: Q2E (page 164)
Question: For the following MIPS assembly instructions above, what is a corresponding C statement?
add f, g, h
add f, i, f
For instructions,
add f, g, h
add f, i, f corresponding C statement is :
f = i+g+h
All the tools & learning materials you need for study success - in one app.
Get started for freeQuestion: The table below shows 32-bit values of an array stored in memory.
2.6.1 For the memory locations in the table above, write C code to sort the data from lowest to highest, placing the lowest value in the smallest memory location shown in the figure. Assume that the data shown represents the C variable called Array, which is an array of type int, and that the first number in the array shown is the first element in the array. Assume that this particular machine is a byte-addressable machine and a word consists of four bytes.
2.6.2 For the memory locations in the table above, write MIPS code to sort the data from lowest to highest, placing the lowest value in the smallest memory location. Use a minimum number of MIPS instructions. Assume the base address of Array is stored in register $s6.
Translate the following MIPS code to C. 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.
addi\)t0, \(s6, 4
add \)t1, \(s6, \)0
sw \(t1, 0(\)t0)
lw \(t0, 0(\)t0)
add \(s0, \)t1, $t0
Question: Write the MIPS assembly code to implement the following C code:
lock(lk);
shvar=max(shvar.x);
unlock(lk);
Assume that the address of the lk variable is in \(a0, the address of the shvar variable is in \)a1, and the value of variable x is in $a2. Your critical section should not contain any function calls. Use ll/sc instructions to implement the lock() operation and the unlock() operation is simply an ordinary store instruction.
Question: Translate into decimal.
Provide a minimal set of MIPS instructions that may be used to implement the following pseudo instruction:
not \(t1,\)t2 // bit-wise invert
What do you think about this solution?
We value your feedback to improve our textbook solutions.