CPSC220: Introduction to Computer Architecture (Fall 2013)

Assignment #3

Due at the start of class on Thursday, 10/03/2013

Summary

This assignment focuses on basic MIPS assembly language programming. You should use the MARS simulator to code and test your work.

Reading

To do

Translate each of the following code fragments into equivalent MIPS assembly programs. For now, we'll ignore problems of input/output and system calls: just test your programs by hard-coding values in the initial memory setup. That, of course, requires some careful though on how to setup appropriate memory and registers in the first place!

  1. int x = 5;
    int y = 7;
    int z = 0;
    if (x < y) 
       z = x;
    else
       z = y;
    
  2. int x = 5;
    int y = x % 2;
    
  3. int y = 125;
    int x = 0;
    while (y > 0) {
       x = x + 1;
       y = y / 2;
    }
    
  4. int[] a = {0,0,0,0,0,0,0,0,0,0,0};
    int i = 0;
    
    while (i < a.length) {
      a[i] = i;
      i = i + 1;
    }
    

Turn in:

To hand in your files: