Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

just by glancing, can someone tell me what im doing wrong? my code is supposed to iterate thru an array and print the elements in

just by glancing, can someone tell me what im doing wrong? my code is supposed to iterate thru an array and print the elements in reverse order but it only switches 2 elements ..

im very stuck :(

image text in transcribed

# COPYFROMHERE - DO NOT REMOVE THIS LINE doSwap: # TODO: translate the following C code into MIPS # assembly here. # Use only regs $v0-$v1, $t0-$t7, $a0-$a3. # You may assume nothing about their starting values. # unsigned int x 0 # unsigned int y 8 # while (x !-4) { #myArray[x] myArrayly # x++ int temp = myArray[x] myArray[y] = temp # y- # TODO: fill in the code # unsigned x 0 la $t0, myArray # unsigned y = 0 addiu $t1, $to, t8 # if x is != 4, exit beq $to, $t1, main_exit lw $t4, 0 ($t0) lw $t5, 0($t1) sw $t4, 0($t1) sw $t5, 0($t0) # increment x by 1 addi $t0, $t0, 4 #decrement y by 1 addi $t1, $t1, -4 # COPYFROMHERE - DO NOT REMOVE THIS LINE doSwap: # TODO: translate the following C code into MIPS # assembly here. # Use only regs $v0-$v1, $t0-$t7, $a0-$a3. # You may assume nothing about their starting values. # unsigned int x 0 # unsigned int y 8 # while (x !-4) { #myArray[x] myArrayly # x++ int temp = myArray[x] myArray[y] = temp # y- # TODO: fill in the code # unsigned x 0 la $t0, myArray # unsigned y = 0 addiu $t1, $to, t8 # if x is != 4, exit beq $to, $t1, main_exit lw $t4, 0 ($t0) lw $t5, 0($t1) sw $t4, 0($t1) sw $t5, 0($t0) # increment x by 1 addi $t0, $t0, 4 #decrement y by 1 addi $t1, $t1, -4

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions