New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

CPSC 321

by: Mozell Lind

CPSC 321 CPSC 321

Mozell Lind
Texas A&M
GPA 3.58


Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 5 page Class Notes was uploaded by Mozell Lind on Wednesday October 21, 2015. The Class Notes belongs to CPSC 321 at Texas A&M University taught by Staff in Fall. Since its upload, it has received 31 views. For similar materials see /class/226086/cpsc-321-texas-a-m-university in ComputerScienence at Texas A&M University.

Similar to CPSC 321 at Texas A&M


Reviews for CPSC 321


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/21/15
Introduction to SPIM Page 1 of 5 CPSC 321501503 Computer Architecture Texas AampM University Department of Computer Science Fall 2006 Lab 1 10 pts Introduction to SPIM Simulator for the MIPS Assembly Language on the UNIX and PC Environments Complete by yourself Release date 4 September 2006 Due date One week following lab Objective This laboratory assignment will help you familiarize yourself with the UNIX and PC environments brie y the spim simulator and other utilities such as text editors You will be using SPIM the MIPS simulator by James R Larus to code and run your first MIPS assembly language program In addition to the SPIM documentation under the Useful Links section of the course Web site your textbook 1 contains a discussion of SPIM in Appendix A on the CDROM You will also learn how to interact with UNIX processes running on a UNIX host from a PC console using the X11 windowing environment Prelab Requirements Before entering the lab make sure that you have your own UNIX and PC accounts and that you can log into them Introduction to SPIM SPIM is a software simulator that loads and executes assembly language programs for the MIPS R2000R3000 RISC computers Assembly is a low level language with instructions that correspond very closely to the machine code that a processor executes SPIM can read and immediately run files containing MIPS assembly language statements SPIM is a self contained system for running these programs and contains a debugger and interface to the operating system The installed version of SPIM is 65 SPIM was written by James R Larus then at the Computer Sciences Department of University of Wisconsin Madison laruscswiscedu SPIM is very portable which allows students to generate code for a simple clean orthogonal computer SPIM currently runs on a wide variety of UNIX and Windows systems SPIM is copyrighted by James Larus and can be freely used for non commercial purposes You can get source and pre compiled files from httpwwwcswiscedularusspimhtml Note If you have a personal computer it is recommended that you download and install SPIM ver 65 on your own machine The Computer Science Labs maintain versions for both UNIX and PC platforms SPIM implements almost the entire MIPS assembler extended instruction set for the R2000R3000 with the exception of some complex oating point comparison instructions and direct manipulation of the memory system page tables The MIPS architecture has evolved considerably since then in particular the 64 bit extensions meaning that SPIM will not run programs compiled for recent MIPS processors fileHwebcoursescpsc321labslab1706chtm 912006 Introduction to SPIM Page 2 of 5 SPIM implements both a simple terminal style command line interface and a visual windowing interface On UNIX the spim program provides a terminal interface and the xspim program provides the X11 window interface On PCs the spim program provides a text interface and PCSpim provides a Windows interface 1 Appendix A or 2 are the best introduction to the software 3 is a detailed language reference MIPS and Laboratory Assignments For the assembly code lab assignments you will use two programs SPIM and a text editor We recommend that you learn to use a real programmer39s text editor That is an editor that is designed specifically for writing computer programs not just an editor designed for arbitrary text such as Pico or Microsoft Notepad We strongly recommend that you use an editor such as EMACS xemacs emacs The department maintains EMACS on both UNIX and PCs SPIM on PC There are two versions of the SPIM for the PC spim a command line version and PCSpim a graphical interface one Look under the StartgtProgramsgtProgramming Tools menu to find these programs You can find emacs under Start gtPrograms gtPublishing Launch PCSpim for Windows SPIM on UNIX Under UNIX there are also two versions of SPIM spim a command line version that runs in a text window and xspim one with a graphical interface Both spim and xspim can be executed from the shell command line Make sure that the file called trap handler is in the same directory from within which you launch xspim or spim Building SPIM on UNIX Systems We maintain copies of the SPIM executables for UNIX xspim spim and their source code on the Useful Links section of the class web page If you desire you can create your own local version Login to your CS UNIX account and create a subdirectory dedicated to cps 0321 Then download SPIM from httpwwwcswiscedularusspimhtml and save the file to the above subdirectory You need to decompress and untar the archive file you downloaded A quick way is to pipe the file through the command sequence gt gunzip ec spimtargz tar XVf e and then build and install SPIM in your account following the instructions in the README file found in this distribution You may ask the TA for help with this Alternatively use the local copy of SPIM on our Web page We recommend that you learn and use xemacs or emacs under UNIX This is family of full featured editors Under UNIX to invoke XEmacs simply type xemacs at the shell prompt A MIPS Assembly Language Program Example In this class we will be studying the MIPS instruction set and its architecture An example MIPS assembly language program is shown below Your first MIPS assembly program Notice the stylized format of the code 3 columns fileHwebcoursescpsc321labslab1706chtm 912006 Introduction to SPIM Page 3 of 5 1 Optional labels 2 Machine instructions assembler directives and their operands 3 Optional comments everything to the right of a 3939 until end of line is ignored data quotdata sectionquot global static modifiable data SID word lOO spcl asciiz quot quot nl asciiz quotnquot tb asciiz quottquot msgl asciiz quotHello Worldnquot msg2 asciiz quotMy name is XXXXXXXXXnquot msg3 asciiz quotnMy name is still XXXXXXXXX 1nquot text quottext sectionquot code and readeonly data globl main declare main as a global symbol main la a0 msgl li v0 4 quotprint stringquot system call syscall la a0 msg2 li v0 4 syscall lw a0 SID la al spcl Loop beg 0 a0 Exit add a0 a0 1 li v0 l quotprint intquot system call syscall move t0 a0 move a0 al li v0 4 syscall move a0 t0 j Loop Exit la a0 msg3 li v0 4 syscall Exit from program li v0 lO quotExitquot system call syscall Requirements for Lab 1 1 Type the MIPS code shown above into a text editor Replace the XXXXXXXXX With your name and then save the file under the name LAB1 s Once you have saved the file run this MIPS assembly program using both the PCSpim and xspim simulators The MIPS assembly code is listed below We will explain the meaning of the instructions in class Load your source file into PCSpim using File gtOpen Then run the program using Simulator gtGo If you typed the sample program in correctly the message successfully loaded will appear in the Messages Window Note the first time you run the program you may get an error message that file trap handler was not found From Simulator gtSettings change the path for the fileHWebcoursescpsc321labslab1706chtm 912006 Introduction to SPIM Page 4 of 5 trap file from the default setting to C ProgramFiles PCSpim trap handler and the problem should go away If your program runs correctly a number of messages should appear in the Console window 2 Run LAB1 s under UNIX as well 3 Write a short paragraph explaining what this program does You do not have to understand the assembly details at this point However you need to be able to tell what the code does in rough terms Save this in a file called LAB1 rep Discuss which environment is better overall for you to use and for which reasons 4 Package the two files into one archive file called LAB1 tar or LAB1 zip in the UNIX PC environment Do not forget to include the student information according to the assignment submission guidelines shown in the class web page 5 Turn in your work using the turnin command Running and Interacting with UNIX from Remote Hosts This section is optional but provides useful information for interacting with UNIX processes from other hosts One very interesting feature of UNIX is the capability to execute and interact seamlessly with commands at remote UNIX hosts UNIX uses the X11 windowing server to make remote command interaction seamless The basic mode of operation is that a remote UNIX host executes any UNIX command but the user interacts with it from another UNIX or PC host This is accomplished by having the host that a user is using run an X11 server The remote command can open an X11 client window on the host with the X11 server and let the user interact with it directly as if the user was sitting on the host that executes the command Interacting with UNIX Applications from a PC To run and UNIX applications from within a PC perform the following steps Locate and launch the X11 server on the PC it is called X Win32 2 Use the ssh command from the PC to login to a UNIX host say to unix cs tamu edu 3 After you login type the command who at the shell prompt You should see a listing of users and at the far right end you should see the host names from which these users have logged on inside parentheses Assume that you are logged from a PC named myPC 4 Then issue the command setenv DISPLAY myPC 0 5 To run a UNIX command type xterm to launch an X11 terminal window which will be displayed on your PC You can then type a UNIX command at the prompt Instead of a terminal window you can just type xspim to launch SPIM on UNIX and interact with it from your PC Interacting with UNIX Applications from other UNIX Hosts To run and UNIX applications from within another UNIX host follow these steps 1 Log on to a UNIX host and launch the X11 server all SUN Solaris workstations at CS run the CDE graphical environment 2 Use the ssh command to login to the remote UNIX host say unix cs tamu edu 3 After logging in type the command who at the shell prompt You should see a listing of users and at the far right end you should see the hosts names from which these users have logged on inside parentheses Assume that you are logged from a SUN workstation called interactive 4 Issue the command setenv DISPLAY UNIX 0 5 To run a UNIX command type xterm to launch an X11 terminal window which will be displayed on your UNIX host interactive You can then type a UNIX command at the prompt Instead of a terminal window you can just type xspim to launch SPIM on the remote UNIX and interact fileHwebcoursescpsc321labslab106chtm 912006 Introduction to SPIM Page 5 of 5 with it from your local UNIX host References 1 David A Patterson and John L Hennessy Computer Organization and Design The HardwareSafmare Interface Morgan Kaufmann Publishers Inc third edition 2005 ISBN 1 55860 604 1 2 James R Larus7 DSPIM 820 A MIPS R2000 Simulator Unpublished Documentation for SPIM7 Computer Sciences Department7 University of WisconsiniMaclison7 httpwwwcswiscedu0a html Latest version is 64 3 Robert Britton7 DMIPS Assembly Language Programming Prentice Hall7 2003 Copyright 2001 2003 Michael E Thomadakis This document may be copied and used for non commercial purposes as long as this copyright notice remains on it This document was converted to HTML and updated in 2006 by Hank Walker fileHWebcoursescpsc321labslab1706chtm 912006


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Anthony Lee UC Santa Barbara

"I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.