Skip to content

About

Andrew Roddy and TJ Raklovitz's Computer Org HW 3 Project

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

54 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Assembly-List-Parser

MIPS Assembly List Processing Program

Authors

  • Andrew Roddy
  • TJ Raklovits

Overview

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.

Features

The program provides an interactive menu with the following operations:

  1. Sort - Sorts the list in ascending order using bubble sort
  2. Calculate Average - Computes the mean of all values in the list
  3. Find Lowest Element - Identifies the minimum value
  4. Find Greatest Element - Identifies the maximum value
  5. Find Sum - Calculates the total sum of all elements
  6. Print Specific Element - Displays a single element at a given index
  7. Print List Contents - Displays the entire list
  8. Exit - Terminates the program

Input Format

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

Technical Details

Data Structures

  • Input Buffer: 100 bytes for user input
  • Array Storage: 500 bytes (up to 125 float values)
  • Floating-point arithmetic using MIPS coprocessor 1

Key Components

String to Float Conversion

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

Bubble Sort Algorithm

Implements a standard bubble sort for floating-point arrays:

  • Compares adjacent elements
  • Swaps elements if out of order
  • Iterates until the list is sorted

State Machine Architecture

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

Register Usage

  • $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

How to Run

Prerequisites

  • MIPS simulator (e.g., MARS, SPIM, QtSpim)
  • Basic understanding of MIPS assembly

Execution Steps

  1. Load main.asm into your MIPS simulator
  2. Assemble the program
  3. Run from the main label
  4. 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

Example Session

#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

Known Issues / Limitations

  • 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

Program Flow

  1. Initialization (setup_stores) - Initialize state registers
  2. Get List (get_list) - Prompt user for list input
  3. Process List (process_list) - Parse brackets and extract numbers
  4. Menu Loop - Display options and process user selections
  5. Operations - Execute selected function (sort, average, etc.)
  6. Exit - Display farewell message and terminate

Code Organization

  • 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

About

Andrew Roddy and TJ Raklovitz's Computer Org HW 3 Project

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages