Description
In this project, you will write a simple simulator for a subset of MIPS instruction set as
defined in ‘Computer Organization and Design: The hardware/Software Interface” 5th
Edition, Patterson and Hennessy.
This project is worth 2 labs.
You can use C or Java. The input to your simulator is the executable program binary.
Your simulator should read the instructions one by one and execute them. Execution of
the instructions means changing the contents of registers and/or memory. Your
simulator should run the program until the end of the file (executable binary), or until
executing a syscall to exit.
Your simulator should be able to execute the following instructions:
sll srl addu add and nor
slt sltu addiu slti lui
Extra credit (25%) will be given if you simulate the following instructions
lb lw lbu sb sw
Keep in mind here that you need to think how to represent the “memory” in your
simulator.
Your simulator should run in one of two different modes. The first line of the binary code
is either 0 or 1. if 0, the simulator simulates the program until the end and then print the
contents of the 32 register $0 – $31. If the first line is 1, the simulator prints the contents
of the 32 registers after it executes any instruction.
Each time the simulator print the registers, it does that in the following format
$0:0x????????. The “$0” means register 0 followed by a colon, then 0x (for hex) then 8
hex digits , then the next instruction 4 registers per line with the last register value NOT
followed by two spaces. After you write all the registers’ values, a new line consists of
40 “=”
The input to the simulator is a file with the first line contains a 0 or 1 (to set the mode)
then one hex number per line, for example
$0:0x421ae210 $1:0x12345678 $2:0xffff1212 $3:0x1111ffff
$4:0x421af210 $5:0x12345678 $6:0xffff1212 $7:0x1111ffff
2 spaces
$28:0x421af210 $29:0x12345678 $30:0x12af1212 $31:0x1111ffff
=======================================
This document will be modified/corrected/”made more clear” frequently. I will
make the correction/modification in red, so please check this site often
0
46540af2
1234abcd

