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

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

Part 0 – Pre-lab – due at start of class on Friday January 18, 2008

a.) Read this entire lab through carefully.

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

c.) Pseudocode: Use a drawing tool or Microsoft Word to construct pseudocode or a flow chart for the Parts 1-2 objective 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)

Follow the instructions in the PCSpim “How To” document (from URL above). 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.

Steps to the Solution:

• Understand the sample program in the How To section of the lab
• Understand which part does what
• DO A DESIGN
• Tackle one step at a time
• It is helpful to have the text editor with your assembly program open

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 version).

DELIVERABLES

Due on Friday January 18, 2008 – start of class

·        Flowchart / pseudocode (your choice)

Due on Wednesday January 23, 2008 – start of class

·        Lab #1 Cover sheet

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

·        Hardcopy of .asm file, 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