Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1 :Assume that the variables f , g , h , i , and j are assigned to registers $s 0 , $s 1

Exercise 1: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.
1) Translating from C to MIPSF=A[1]+B[3]For the C statement above, what is the corresponding MIPS assembly code?
2) Translating from MIPS to Clw $s0,4($s6) For the MIPS assembly instructions above, what is the corresponding C statement?
Exercise 2:Assume that the variables a and b are assigned to registers $s0 and $s1, $s2 respectively
a = a +4;
b = a -12;
Exercise 3:Translate the following assembly language statement into machine language.
1) add $s0, $s1, $s2
2) sub $t0, $t3,$t5
3) addi $s0, $s1,5
4) lw $t2,32($0)
Exercise 4: Shift operationsAssuming that the value to be shifted 0xF30002A8 is in $s1, Calculate the shifted value in each instruction described below.
(1) The first instruction shifts the value from $s14 bits to the left, and places the result in $t0.
(2) The second instruction shifts the value from $s14 bits to the right, and places the result in $s2.
(3) The third instruction shifts the value from $s14 bits using the shift right arithmetic (sra), and places the result in $s3.
Exercise5 :
1) Translate the following high-level code to the MIPS code
if (i == j)
f = g + h;
f =f - i;
2) Translate the following high-level code to the MIPS code
if ((a >0) && (b>0)
c =(a - b)+A[5] ;
Else
a++;
Assuming that a, b and c in $s1, $s2 and $s3 and the base address of A in $s5.

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions