You are on page 1of 1

!"!#$%&'$($!)*+,-./$0/123452-4)3$236$788.*9:;$<231,21.$=/)1/2**431$$ "+/431$%>'?$ ! ! !"#$%&'()*+,-# =/)@.A-$'B$CD="$"4*,:2-)/$236$E48288.*9:.

/$

An assembler is a program that translates programs written in assembly language into machine code. Machine code is essentially the binary equivalent of the assembly language. Translating from assembly language to machine code is straightforward process using the instruction formats specifications. A disassembler works in reverse. It takes machine code and produces the equivalent assembly language program. At times, the machine code may not have all the information that the assembly language program contains. In particular, comments are typically removed, and labels are also removed. An ISA simulator is a program that accepts machine code of compiled/assembled program and mimics what a real CPU hardware would do to execute the program instructions. The simulator shows the effect of simulating the instructions execution as memory location(s) and register(s) changes.

."#/01+2)030,45#
2.1 Essential Requirements (100%) You are required to develop a disassembler/simulator for a subset of MIPS instructions using a programming language of your choice (C/C++ is preferred and a C++ skeleton is given). Your program must: Read MIPS machine code file. The file is just a binary file that contains the machine code of all instructions. The first 4 bytes in the file belong to the first instruction; the 2nd 4 bytes belong to the 2nd instruction, etc. The first instruction is assumed to be at location 0x00400000 in the main memory. Decode each machine code word and translate it into a true MIPS instruction. Interpret the decoded instruction. As a result, the instruction execution will modify the registers and/or the memory and/or execute the requested SYSCALL service. Print out the disassembled code on the screen. Be invoked from the command line using the syntax:

mipsim <machine_code_file_name> !

Where:

<machine_code_file_name> i"!#$%!&'(%!)*+%!,&!#$%!')-.#!+*/$')%!/,0%!
If you don't know how to pass parameters using the command line to a C/C++ program, read this. The disassembler/simulator should be able to decode the following instructions: add, addi, addu, addiu, sub, and, or, xor, andi, ori, xori, lw, sw, sb, lb, lh, sh, beq, bne, slt, slti, j, jr, jal, srl, sll, lui and syscall. Also, your disassembler/simulator should be able to execute the following SYSCALL services: o Print integer (Service 1), o Print a string (Service 4) and o Terminate execution (Service 10).

2.2 Optional Requirements (20%) Use register names instead of register numbers in the disassembled code (e.g., $zero instead of $0) [5%]. Convert true MIPS instructions to pseudo-instructions whenever possible (move, li, la, subi) [8%]. Use labels instead of addresses for Jump and Branch instructions [7%].

6"#7+2-082,05#

1. Work in a group of 2 students. 2. You may use the supplied Skelton.cpp as a starting point for your code. Also, 2 machine code files are supplied for testing purposes. You can generate more files from MARS (File->Dump Memory). 3. You need to submit a working disassembler binary and source code to the TA (Make sure that the email subject is CSCE231: Proj-1) before March 15th, 2014 11:59PM. 4. You must email Dr. Shalan to reserve a demo slot (5 minutes) on Sunday March 16th 1:00-2:00PM (first come first served).

You might also like