Lab #1 Familiarity with PCSpim and Introduction to Writing Assembly Code

http://www.usna.edu/Users/cs/lmcdowel/courses/ic220/spim/

 

Note: if you are in a Michelson lab, you do NOT need to download/install PCSpim.

 

Part 0 – Pre-lab – due at start of class on Friday January 21, 2011

a.) Read this entire lab through carefully.

b.) Read “PCSPIM Overview” from the URL above.

c.) Create and turn-in: Use a drawing tool or Microsoft Word to construct pseudocode or a flow chart for the “Program objective” for parts 1-2 described below.  This can be at a high-level – you shouldn’t need more than 10-20 lines of pseudocode.  Print two copies – one to turn in and one to use in lab.

 

Program objective (for Parts 1-2): Write a program that first prints your name and lab identification in a “welcome message” to the console, followed by a newline. The program then prompts the user for a number, adds 5 to the original number, adds the number to itself, and multiplies the original number by 8. Your program will output each answer individually, with text preceding the answer, such as “x+5 is”, “8*x is”, etc. Each line of output must appear on a separate line.

To perform multiplication, it is suggested that you use instructions that we have already learned in class (a single one will suffice), though if you wish you can figure out how the multiply instruction works and use that.

 

Part 1 – Getting started with SPIM (do this in lab)

Go to the URL above, and follow the instructions in the “PCSpim-HowTo: Installing and Starting SPIM” document. Look carefully at the sample program.

 

Part 2 – simple program

Write a .asm file that implements the program above.  You may wish to base your solution on the sample program.

Tips:

 


Part 3 – iterative program

(suggestion – save a backup copy before you start this)

At the beginning of your program, ask the user how many times he would like to repeat the program (call this ‘N’ times).  Then, N times, ask for an x and do the calculations and output.  However, you should only print the welcome and farewell message once.  Turn in only one copy of your program (the improved, Part 3, version).

 

DELIVERABLES

Due on Friday January 28, 2011 – start of class

·        Lab #1 Cover sheet (see course home page)

·        Screenshot of your code executing for N=3, with x = 12, then 17, then 20

·        Hardcopy of your .asm file (with comments), stapled to your cover sheet

·        Digital copy of .asm file – copy this into your X: drive inside a folder named “IC220Lab1”.  Name your file as follows: Lab1-section-lastname.asm. Example:  Lab1-2001-smith.asm

 

Your hardcopy and the file in your X drive must identical.  In addition, your file must be commented.

 

Unless you are very quick, you’ll start this lab during classtime and finish it for homework.  To use PCSpim you can either come to the lab in Michelson or install PCSpim on your own PC; see the install instructions at the link above.