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.
- z = (x * 3 + y + 1)/z
- 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.
- B[0] = A[1] + A[2] + A[3];
- B[g] = A[f] + A[f+1];
- B[j] = A[f] + A[g] + A[h] + A[i];
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started