Unit 3 - Instruction Set Overview
and the SPIM Simulator
Instruction Set Overview:
For an overview of the MIPS R2000 Assembly language
instructions, look here.
Installing SPIM:
- Run the SPIM Installation
File from the class directory I:\1502-prj\1502\Spimwin.exe and install
into your home directory (i.e. I:\\PCSpim).
- A new folder will be created
on the local portion of your Start/Programs menu called PCSpim for Windows
with a shortcut PCSpim for Windows. Use this shortcut to start
PCSpim.
Introduction to SPIM:
- Download the the example file
Unit3Example.s into the PCSpim directory.
- Start PCSpim.
- Go to File/Open and open the
file Unit1Example.s
- Display all of the status
windows by selecting Window/Tile.
- Step through the example file
using the Simulator/Single Step menu item or the F10 key.
Observe the changes in the registers in the Registers window as
instructions are executed.
Assignment:
You are to write an assembly language program which will
read a packed string of eight characters from a specified memory location,
check to make sure that each character is a digit from (0-9), and then convert
the string of digits into its corresponding integer value and place this value
in a specified register. If a character is not recognized as a decimal
digit, then call an error routine which sets the value of the result register
to 0xFFFFFFFF. The string will be initialized into memory using a .data
section in your assembly language code to store an ascii string 8 characters:
.data
STRING1: .asciiz "76543210"
The above code will load the ascii character '7' into the byte at address
STRING1, the ascii character '6' into the byte at address (STRING1 + 1), etc. The ASCII string is terminated by a NULL (value 0) character.
It may be useful to use the R2000 Assembly language routines mult rs, rt
; div rs, rt ; and mflo rd, rs
Here is a rough sketch of an algorithm that can be used to accomplish this:
- Clear the result and index registers
- Load the byte at label
STRING1 using your index register into a register $x
- Check to make sure that the
character is not the NULL character. If so, branch out of the loop.
- Check to make sure that the
character is a decimal digit (between 0x30 and 0x39). If not, branch to an error routine.
- Multiply the result register
by 10.
- Subtract 0x30 from the value (to convert from ASCII to binary) and add it to the result register.
- Return to step 2.
- Return to calling routing (jr
$31)
Remember, DO not use register $0, $1 or $31 in your code
(except for jr $31 to return), SPIM reserves them for its use.