CPSC 220 Introduction to Computer Architecture Fall 2008

Lab 6: Larc Machine Programming

Introduction

In this lab, which is due next week, you will write a Larc machine program. You will need to use your notes from class and the two handouts on Larc: Larc ISA and Larc machine programming.

Setup

Create a lab06 directory within the ~/cs220 directory that you created in lab 1 for use in this lab. Change to the newly-created lab06 directory. Copy the provided files from the directory /classes/f08/cs220/labs/lab06 to your new lab06 directory. The following commands should work (note: the "-r" in the cp command allows for copying directories as well as files):

bash$ mkdir ~/cs220/lab06
bash$ cd ~/cs220/lab06/
bash$ cp -r /classes/f08/cs220/labs/lab06/* ~/cs220/lab06/

Note: the rest of this lab assumes you are in your lab06 directory.

The file sim should have been copied to your working directory. sim is a working simulator that will allow you to run Larc machine code programs. To run a program called hello-world.out you would do the following:

bash$ ./sim hell-world.out
Hello, world!
bash$

Exercises

There is one exercises for this week's lab due next week. Remember to use good programming style as laid out in lab 1.

  1. In this exercise you will write a Larc machine code program, called num-lc-a.out. Your program should prompt the user for a string and then print out the number of lowercase as found within the string. Below is a sample run of the program (user input is underlined). Your program should work exactly like the one below (including the formatting).

    bash$ ./sim num-lc-a.out 
    Enter some text: adsAa 
    You entered 2 a's. 
    bash$ 
    

    Before starting the program, it is critical that you write the algorithm. Use your notes from class and Section 6.1 of the textbook to guide you in writing the algorithm. In fact, you will be graded on your algorithm as well as your final program. In particular, your algorithm should be in english (as opposed to machine code), detailed, clear, and unambiguous. Put your algorithm in a file called num-lc-a-alg.txt. When you have completed your algorithm, you can then (and only then) translate the algorithm into Larc machine code. Once you have done this, you can run and test it with the provided simulator. To run the simulator, type ./sim into the shell as shown in the example above.

    Note: you need to submit the files num-lc-a.out (program file) and num-lc-a-alg.txt.

Handin

Verify that your lab06 folder contains all of the files you created or modified for this lab, then copy your entire lab06 folder to the handin directory ~mcorliss/handin/cs220/username (where username is replaced with your username). For example, if your working directory is ~/cs220/lab06/ then you could do the following:

cp -r ~/cs220/lab06 ~mcorliss/handin/cs220/username

where username is replaced with your particular username (e.g., mcorliss).


Good luck and have fun!