DOC PREVIEW
GT ECE 2030 - ECE2030 SPIM HOMEWORK

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

ECE2030 SPIM HOMEWORK“Getting Familiar with SPIM”DUE: Nov. 15, 2002Type in the following program using a text editor (not a word processing package!) and execute it using PCSpim. PAYATTENTION TO THE SPACES IN THE ASCII DIRECTIVES! There is a bug in PCSpim: you have to leave ablank line at the end of the program. To become familiar with the simulator it is useful to go through the followingsequence of steps.• FIRST download simulator and run through the on-line tutorials in the NEXT Section of the notes labeledPCSpim Tutorial• Load the program into SPIM. If you typed it in correctly it should load with no errors. If there aretypographical errors then a dialog window will pop up with the line number. Other wise open the Consolewindow and you can check the error message. Continue to edit/load until all errors are taken care of.• Run the program. Answer the questions in Problem #1 and see the results. The program should run with noproblem.• Look in the data segment. It will be filled with values starting at address 0x10010000. These values areproduct of the data directives in the program.• Check the text segment. You will see instructions at each successive address in the text segment. Learn toassociate addresses with instructions.• Open the registers window and you will see the contents of all 32 registers. Check the register’s contentsbefore and after running the program.Answer the following questions1. After loading the sample program on following page into the SPIM simulator, what are the contents of the second,third, and fourth word in memory?2. Indicate the type of computer you are using to run the SPIM simulator, and after looking at the contents of the datasegment, indicate if the machine uses big endian or little endian convention to store words.3. How many bytes of data are being used in the data segment?4. At what address does the data segment begin?SPIM Sample Program#################################################################### INSERT YOUR NAME# ECE 2030 ( E or F)# SPIM Homework#1##################################################################### Comments begin with the ‘#’ character# Begin the data segment (declare variables).data.asciiz “SPIM is COOOOL!!!”.byte 0xF2.align 2 # enforce word alignment.word 0xF28343AAnum1: .word 89num2: .word 7result: .word 0result: .word 0.textlw $t0,num1lw $t1,num2add $t2, $t0, $t1sub $t3,$t0,$t1sw $t3, result1sw $t4, result2# end execution of the programli $v0, 10syscall# A bug in SPIM requires you to have an extra carriage return after the last line ofcode.PCSpim for Windows TutorialPCSpim for Windows is an emulator for the MIPS instruction set. You can download it from the followingURL: ftp://ftp.cs.wisc.edu/pub/spim. You should get the “spimwin.exe” file from that location. SPIMallows you to run simple programs written in the MIPS assembly language. Your program can interactwith the user with an emulated command prompt (the “console”). While your program is running, you canexamine the state of the emulator including the data storage and the program being run. A local SPIMPCSPIM tutorial page is available at http://users.ece.gatech.edu/~sudha/2030/temp/spim-isa/spim-isa.html.Check the link to the tutorial page.Note that SPIM doesn’t have a built-in text editor, so you’ll have to use Notepad or some other editor tocreate your assembly files. Assembly files are saved as plain text files with a “.s” file extension (e.g.,“lab.s”). Each line of the file is either a comment, an instruction to the emulator, or a MIPS assemblyinstruction.When a program is read in, it is divided into data and program code. The memory model used by the SPIMemulator has a “text” segment (where your program goes), a “data” segment (where declared variables are),and a “kernel.” The kernel code imitates the functions that an operating system would normally provide;you should never have to do anything with it.Interaction between your emulated program and a user is accomplished with a window in SPIM called the“console” window. Special functions are provided for screen input and output.MENUs in PCSpimNote: the menus have more options than the ones listed here. These are the options you’ll probably usemost often. Feel free to play with the others.FILE-open: This loads an assembly source code file (a .s file) and prepares the emulator to run it.The program will be put in the text segment and the data declarations will be put in the data segment. Ifyou get an error window when you open your .s file, try opening the settings and turn off the loading ofthe trap file. If the message windows appears with syntax errors listed in it, you’ll have to correct yourassembly code (using Notepad or another editor) and then try to open the file again.-exit: Closes SPIM.SIMULATOR-reload: Restarts the simulator and re-reads assembly file you have open. Use this if you run yourprogram, make changes to it (in your editor), and want to run it again to see if the changes worked. Notethat SPIM can sometimes get confused and reloading won’t fix it. In these cases, close SPIM completelyand restart it.-go: Starts running the program. It lets you choose what you want the program counter to start at (i.e.,it lets you choose which line of code to start running at). Your program always begins at 0x00400000,the beginning of the text segment.-break: This stops the assembly program wherever it might be. You can look at what values areheld in data memory, the registers, and you can see what line of code was being executed. This is usefulwhen you are debugging—especially if you think you are getting stuck in an infinite loop.-single step: Run next instruction only, then break. Use this to watch register and data valueschange as your program runs and to see which instructions are being run. You can run a single step afterbreaking or to start the program at the first instruction (0x00400000).-set breakpoints: This is yet another debugging trick. Suppose you are suspicious of a certainsection of your program, and want to watch it run. Open your assembly file and look at the text segment.Find the instructions you want to watch in the text segment. Click on Simulator then Set Breakpoints andenter the address of the instruction that begins the portion of code you want to watch. Now when you runyour program SPIM will


View Full Document

GT ECE 2030 - ECE2030 SPIM HOMEWORK

Documents in this Course
Load more
Download ECE2030 SPIM HOMEWORK
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view ECE2030 SPIM HOMEWORK and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view ECE2030 SPIM HOMEWORK 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?