CSCI 210: Lab 1

Intro to MIPS
Due: 11:59 PM on Sunday, June 14

Write a program which takes in a number and stores it in a four-element array at a user-specified index, then prints the contents of the array. You will write this program using the MARS MIPS simulator, which you can download here. Check out the lab template from github here.

Program Specification

Read two input values from the keyboard:

  • a number to enter in the array
  • the index of the array where you should store it.

Print out each index of the array, and its contents. This will look like:


  Please enter a number 6
  Which element of the array would you like this to be? 1
  0: 0
  1: 6
  2: 0
  3: 0

  Please enter a number 3
  Which element of the array would you like this to be? 0
  0: 3
  1: 0
  2: 0
  3: 0

You can assume the user will not input any indexes outside of the bounds of the array. You are required to store the user's value in memory at the specified position, and to load every value in the array from memory into a register to print it out.

Note that you will need to translate between indices, which are word addresses, and values in memory, which are byte addresses.

Make sure to document your programs thoroughly. (This is especially important in assembly language programs, since the code itself is less easily read than high-level language code.) This should include:

  • A block of comment lines at the beginning of the source file, giving the name and author of the program and a black-box description of what it does.
  • A few comment lines between major sections of the program, describing the contents of each section.
  • A comment at the end of most source lines, describing what the instruction on that line does.

Helpful Resources

Hints

  • You will need to use various system calls to print strings, integers, etc - these are all provided on the list of system calls linked from the lab.
  • The la instruction loads the address of a label. You can use this to load the addresses of any of the variables in the .data section of your code.
  • The mul instruction will allow you to multiply a register by a constant.
  • I have included some strings you may find helpful in the .data section.

Submit the lab by committing to your lab1 github repository.


C. Taylor