Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

e. What do you know about your ethnic background?

Answered: 1 week ago

Question

b. Why were these values considered important?

Answered: 1 week ago