Question: I. Arithmetic Operations For the following C statement, write the corresponding MIPS assembly code. Assume that the variables x, y, and z are assigned to

I. Arithmetic Operations

For the following C statement, write the corresponding MIPS assembly code. Assume that the variables x, y, and z are assigned to registers $s0, $s1, and $s2, respectively. Use a minimal number of MIPS assembly instructions. You can use temporary registers for intermediate values ($t0 ~ $t9) if needed.

Hint: execution order of arithmetic operations are very important.

  1. z = (x * 3 + y + 1)/z
  2. z = ++x * y--;

II. Memory Access

Assume we have variables f, g, h, i, j stored in $s0, $s1, $s2, $s3 and $s4, respectively. Assume the base addresses of integer arrays A and B are at $s6 and $s7.You can use temporary registers for intermediate values ($t0 ~ $t9) if needed.

Hint: Effective address = constant value + base address from load/store instructions. For example, lw $t1, 16($t0), the effective address of Memory = 16 + value of $t0. This instruction read a value from a location integer Array[4]. Integer is 4-byte (word) size, scaled by 4 in address.

  1. B[0] = A[1] + A[2] + A[3];
  2. B[g] = A[f] + A[f+1];
  3. B[j] = A[f] + A[g] + A[h] + A[i];

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!