
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Introduction In this lab you will write a short program in MIPS assembly code and simulate it using SPIM. This will familiarize you with the MIPS instruction set architecture.
Design Requirements Your goal is to write a complete program in MIPS assembly language that implements the bubble sort algorithm to sort a variable-sized array of signed 32-bit integers (words) read from the console. A “special value” of 9999 will be used to signify the end of the input. This value will not be used as part of the sort data.
Use the following pseudocode algorithm:
n =0;
do { read in vals [ n ]= in n = n + 1 } while in != 9999
n = n - 1
for i = 0 to n -2 do { for j = 0 to n -2 do { if vals [ j ] > vals [ j +1] then swap elements } }
for i = 0 to n -1 do { print vals [ i ] }
System call 5 ($v0=5) reads an integer from the console (returns to $v0), while system call 1 ($v0=1) prints an integer to the console (input in $a0).
Use the following line to initialize memory to hold the input (note that vals is essentially a label pointing to the start of the data segment):
.data vals:
What to Submit Submit your code via CSE Dropbox (via https://dropbox.cse.sc.edu)