Question: Answer question #1 I already have the code but I need it to quote Show all the details of your work. And carefully explain the

Answer question #1

I already have the code but I need it to quote "Show all the details of your work. And carefully explain the way you have solved problems."

Answer question #1 I already have the code but I need it

Answer

.data msg1: .asciiz " Please enter numbers: " msg2: .asciiz "," msg3: .asciiz "This is Bubble Sort" msg4: .asciiz "***PASS***" msg5: .asciiz " " msg6: .asciiz " Sorted " .text .globl main main: move $s0,$gp addi $t0,1 add $t1,$zero,$zero add $t2,$zero,$zero add $t3,$zero,$zero add $t6,$zero,$zero add $t4,$zero,$zero sub $t7,$zero,1 li $v0,4 la $a0,msg1 syscall add $s1,$s0,$zero entervalues: li $v0,5 syscall beq $v0,$t7,bubblesort sb $v0,0($s1) addi $s1,1 add $t5,$s1,$zero j entervalues bubblesort: add $t4,$s0,$zero addi $t6,1 #s1-1 -> s0 sub $s1,$s1,$t0 beq $s1,$s0,ending #s0 -> s1 add $s2,$s0,$zero loopinterno: lb $t1,0($s2) lb $t2,1($s2) slt $t3,$t2,$t1 beq $t3,$zero,proximo sb $t2,0($s2) sb $t1,1($s2) proximo: addi $s2,1 bne $s2,$s1,loopinterno li $v0,4 la $a0,msg5 syscall li $v0,4 la $a0,msg4 syscall li $v0,4 la $a0,msg5 syscall imprime: li $v0,1 lb $a0,0($t4) syscall li $v0,4 la $a0,msg2 syscall addi $t4,1 bne $t4,$t5,imprime jal bubblesort ending: li $v0,4 la $a0,msg6 syscall li $v0,5 syscall 

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]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!