Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer the 2nd question Show all the details of your work. And carefully explain the way you have solved problems. 1) (60%) Assume that the

Answer the 2nd question

Show all the details of your work. And carefully explain the way you have solved problems.

image text in transcribed

1) (60%) Assume that the base address of an initialized array, 'arr', with 'n' integers, is stored in Svo. Where, 'n' is stored in $v1. The compiler allocates $50, $s1, and '$s2' as the registers for holding the variables '1', '1', and swapped, respectively. You can use Tregisters as temporary registers. Convert the enclosed C++ Bubble Sort code snippet, taken from geeksforgeeks.org, into assembly. Note that Swap&arr[i], &arr[j+1]) is a pseudo instruction and not as a function void bubbleSort(int arr[], int n) { int i, j; bool swapped; for (i = 0; i arr[j+1]) { (Swap &arrij], &arr[j+1]); // Swap(&arr[i], &arr[j+1]) is a pseudo instruction and not as a function swapped = true; } } // IF no two elements were swapped by inner loop, then break if (swapped == false) break; } } 2) (40%) Write the MIPS code for the following pseudo instructions. You can only use Sat as a temporary register. The meaning of the operator' E || Ez is that the order of evaluating the expressions E., and E does not affect the result. That is, evaluating Ez, before Ez or Es before Ea yields the same result i) 'swap $v0, $v1'. //Use the following algorithm & assume that $vo and $v1 are even integers. $v0 +($+$v1)/2; || $v1 + ($VO-$v1)/2 $v1 ($v0+$v1); || $v0-($v0-$v1) ii) 'ilw $vo, offset ($v1)'. // Pointer to a pointer $v0+ Memory [Memory [Offset + $v1]] 1) (60%) Assume that the base address of an initialized array, 'arr', with 'n' integers, is stored in Svo. Where, 'n' is stored in $v1. The compiler allocates $50, $s1, and '$s2' as the registers for holding the variables '1', '1', and swapped, respectively. You can use Tregisters as temporary registers. Convert the enclosed C++ Bubble Sort code snippet, taken from geeksforgeeks.org, into assembly. Note that Swap&arr[i], &arr[j+1]) is a pseudo instruction and not as a function void bubbleSort(int arr[], int n) { int i, j; bool swapped; for (i = 0; i arr[j+1]) { (Swap &arrij], &arr[j+1]); // Swap(&arr[i], &arr[j+1]) is a pseudo instruction and not as a function swapped = true; } } // IF no two elements were swapped by inner loop, then break if (swapped == false) break; } } 2) (40%) Write the MIPS code for the following pseudo instructions. You can only use Sat as a temporary register. The meaning of the operator' E || Ez is that the order of evaluating the expressions E., and E does not affect the result. That is, evaluating Ez, before Ez or Es before Ea yields the same result i) 'swap $v0, $v1'. //Use the following algorithm & assume that $vo and $v1 are even integers. $v0 +($+$v1)/2; || $v1 + ($VO-$v1)/2 $v1 ($v0+$v1); || $v0-($v0-$v1) ii) 'ilw $vo, offset ($v1)'. // Pointer to a pointer $v0+ Memory [Memory [Offset + $v1]]<-1><-1>

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions