CS 61 - Computer Organization & Assembly Language

Assignment 3 - due via electronic turnin by Saturday August 20, 2005 11pm

This program should be written in LC-3 assembly.

For this project, you will act as the compiler and translate the following C++ subroutines into assembly language. The functionality of your code must be identical to that of the C++ code. In other words, if the C++ code contains a for loop, you should emulate a for loop, and if the C++ code contains a function call, your code should also contain a function call.

You must also write a "main" function that calls each of these functions with proper inputs and verifies their functionality.

The functions are:

 
    int sum(int array[], int size)
    {
      ins runningSum = 0 ;
      for (int i = 0 ; i < size; ++i)
      {
        runningSum += array[i] ;
      }
      return sum ;
    }
    char toLower(char x)
    {
      if (x >= 'A' && x <= 'Z')
      {
        return x + 32 ;
      }
      else
        return x ;
    }
    void printLower(char array[], int size)
    {
      for (int i = 0 ; i < size; ++i)
      {
        array[i] = toLower(array[i]) ;
      }
      cout << array << endl ;
    }
    

What to turnin

Turn in your source code (the .asm file) making sure that your name, id, and all relevant information is located in a block of comments at the top of the file.