Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

///In MIPS ASSEMBLY language Problem: - Create a MIPS program that runs in the MARS simulator. The program must bubble sort an array of 30

///In MIPS ASSEMBLY language

Problem:

- Create a MIPS program that runs in the MARS simulator. The program must bubble sort an array of 30 random integers. The array must be allocated ON THE STACK, as shown above. The program must print the sorted numbers at the end.

Example of how to get a random number and print it:

image text in transcribed

This example allocates an array of 2 integers on the stack, puts random numbers in it, and prints it out:

image text in transcribed

- data NEWLINE: , asciiz " n - text - globl main \#required main: \#required addi $sp,$sp,8 \# make space for 2 ints, 8 bytes on the sto li $a0,0 \#set up random number system call. use generator 0 li $al,100#max random number is 100 li \$v0, 42 \# syscall 42 is random number in a range syscall \# random number is now in sad sw $a0,0($sp) \# store the number in array location [0] syscall \# random number is now in sa0 sw $a0,4($sp) \# store the number in array location [1] \# NOTE I am making the array atart at a lower address \# and go UP in memory! \#now print out the numbers li $v0,1 \#set up to print int lw $a0,0($sp) \#get the int to print syscall li \$v0, 4 \#set up to print a string la \$a0, NEWLINE \#la is LOAD ADDRESS. newline is declared \#at the start of the program syscall li $v0,1 \#set up to print int lw $a0,4($sp) \#get the int to print syscall li \$v0, 4 \#set up to print a string la $a0, NEWLINE \#la is LOAD ADDRESS. newline is declared \#at the start of the program syscall li \$v0, 10 \# last 2 lines are required to make program exit syscall

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions