MIPS Assembly List Processing Program
- Andrew Roddy
- TJ Raklovits
This is a MIPS assembly program that processes lists of floating-point numbers. The program allows users to input a list in bracket notation (e.g., [1.5, 2.3, 4.7]) and perform various operations on the data.
The program provides an interactive menu with the following operations:
- Sort - Sorts the list in ascending order using bubble sort
- Calculate Average - Computes the mean of all values in the list
- Find Lowest Element - Identifies the minimum value
- Find Greatest Element - Identifies the maximum value
- Find Sum - Calculates the total sum of all elements
- Print Specific Element - Displays a single element at a given index
- Print List Contents - Displays the entire list
- Exit - Terminates the program
The program expects input in the following format:
[num1, num2, num3, ...]
Examples:
[1.5, 2.3, 4.7, -1.2][10, 20, 30][-5.5, 0, 5.5]
The program supports:
- Positive and negative numbers
- Integer and decimal (floating-point) values
- Whitespace between elements
- Lists with varying numbers of elements
- Input Buffer: 100 bytes for user input
- Array Storage: 500 bytes (up to 125 float values)
- Floating-point arithmetic using MIPS coprocessor 1
Custom parser that converts ASCII strings to IEEE 754 floating-point numbers:
- Handles negative numbers (minus sign)
- Parses decimal points
- Skips whitespace
- Returns result in
$f0
Implements a standard bubble sort for floating-point arrays:
- Compares adjacent elements
- Swaps elements if out of order
- Iterates until the list is sorted
The program uses register-based state machines:
$s0: Main program state (0-4)$s1: User menu selection (-1 = none)$s2: List processing state (0-3)$s3: Start position of list$s4: Number of elements in list
$s0-$s5: State and configuration registers$t0-$t7: Temporary computation registers$f0-$f12: Floating-point registers$a0-$a1: Function arguments$v0: Syscall codes and return values
- MIPS simulator (e.g., MARS, SPIM, QtSpim)
- Basic understanding of MIPS assembly
- Load
main.asminto your MIPS simulator - Assemble the program
- Run from the
mainlabel - Follow the on-screen prompts:
- First, enter your list in bracket notation
- Then select operations from the menu
- Continue until you choose option 8 to exit
#input
This is the list sorting program.
Please enter a list to process
[5.5, 2.1, 8.3, 1.0]
Please select an option
1. Sort
2. Calculate average of all values.
...
#input
2
Averaging
4.225
- Array size limited to 125 elements (500 bytes / 4 bytes per float)
- Input buffer limited to 100 characters
- Minimal error handling for malformed input
- Print element function doesn't validate array bounds
- Initialization (
setup_stores) - Initialize state registers - Get List (
get_list) - Prompt user for list input - Process List (
process_list) - Parse brackets and extract numbers - Menu Loop - Display options and process user selections
- Operations - Execute selected function (sort, average, etc.)
- Exit - Display farewell message and terminate
- Data Section: String constants and buffers
- Text Section: Code organized by functionality
- Setup and initialization
- String parsing
- Sorting algorithm
- Statistical operations (min, max, avg, sum)
- I/O and menu functions
- Main state machine