Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert into MIPS for (int i = size-1; i > 0; i--) for (int j = 0; j < i; j++) { if (nums[j] >

Convert into MIPS

for (int i = size-1; i > 0; i--) for (int j = 0; j < i; j++) { if (nums[j] > nums[j+1]) { int tmp = nums[j]; nums[j] = nums[j+1]; nums[j+1] = tmp; } } }

use following MIPS code

#int tmp = nums[j]; #nums[j] = nums[j+1]; #nums[j+1] = tmp; sll $t0, $s1, 2 # sll Shift left logical add $t0, $s1, $s0 # this is for j lw $s2, 0($t0) # Since tmp is a variable, it must be a register. Since nums is an array, nums[j]is in RAM. The code #takes nums[j]and puts it in tmp. It therefore is taking RAM and putting it in a register (so, a lw).

addi $t1, $t0, 4 # address of j+1 lw $t2, 0 ($t1) # Repeat line 65 also using lw sw $t2, 0($t0) # nums[j+1] to nums[j] sw $s2, 0($t1) # tmp to nums[j+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_2

Step: 3

blur-text-image_3

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

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

What are the major changes that are being introduced into UHSMCs?

Answered: 1 week ago

Question

Can workers be trained in ethics? How? Defend your answer.

Answered: 1 week ago