Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is using MARS (MIPS Simulator) (Version MARS 2194_a or 2194_11a) Versions can be accessed through : https://luisfnqoliveira.github.io/CS447/resources/ This code is supposed to get the

This is using MARS (MIPS Simulator) (Version MARS 2194_a or 2194_11a)

Versions can be accessed through : https://luisfnqoliveira.github.io/CS447/resources/

This code is supposed to get the user's input and put them into an array that is ordered and prints the array out. I have the code thus far that get's the user's input and puts them into the array. I don't know how to order them then print the array. My current code is displayed below and an example of what the output could be is below the code.

.data list: .word 0:10 request_for_input: .asciiz " Insert a number: " strContents: .asciiz "The contents of the array are: "

.text .globl main main:

# variable i is in register s0 move s0, zero # for( i = 0;

_main_forInsert: bge s0, 10, _main_endForInsert # i < 10; # i++) (*) check before main_endForInsert ## For implementation # Print request for input li v0, 4 la a0, request_for_input syscall # print_string(" Insert a number: "); // syscall

# Get user input li v0, 5 syscall move s1, v0 # Copy the result of the syscall (v0) containing the user input into s1

# write list[i] # Calculate the memory address of list[i] la t1, list # Load the address of the list li t2, 4 # Load the size of a word mul t3, s0, t2 # Multiply i by the size of a word (i*4) add t4, t1, t3 # Calculate the memory address of element i (list +i*4) # Store the user value sw s1, 0(t4) # list[i] = s1

addi s0, s0, 1 # (*) i++ j _main_forInsert

_main_endForInsert:

# Exit li v0, 10 syscall

Possible output:

Insert a number: 10 Insert a number: 9 Insert a number: 8 Insert a number: 7 Insert a number: 6 Insert a number: 5 Insert a number: 7 Insert a number: 2 Insert a number: 3 Insert a number: 4 The contents of the array are: 2 3 4 5 6 7 7 8 9 10

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

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

5. What is the power of a test and how is it related to b?

Answered: 1 week ago

Question

How do we organise for international logistics?

Answered: 1 week ago

Question

What are the logistics implications of internationalisation?

Answered: 1 week ago