Docsity

MIPS Assembly Programming Assignment 1: Implementing a Simple Disassembler, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
ECE3055 Prof. H.-H. S. Lee
Georgia Tech Page 1 of 2
ECE3055 Fall 2006
Programming Assignment 1
MIPS Assembly Programming
Assigned: Sept 18, 2006 Signoff before: Sept 27, 2006 before class
Score: ____________ Date:___________ Name:__________________________________
TA Signoff: ________________________________________________________________
In this programming assignment, you will implement a simple disassembler program using MIPS
assembly language for the Mini-MIPS ISA defined below. You will use the MIPS functional
simulator “SPIM” (http://www.ece.gatech.edu/~leehs/ECE3055 Click on Assignments -> My
SPIM page) for validating the functionality of your MIPS disassembler program. Your program
should disassemble and only disassemble the 6 instructions defined in our mini-MIPS ISA from
the binary words provided. All other binaries not belonging to any of the 6 instructions should
print out “unsupported opcode !!” First of all, you have to download the ece3055p1.s skeleton
file from our course website (http://www.ece.gatech.edu/~leehs/ECE3055 click on Assignments-
>Skeleton Program). This skeleton file contains 14 instructions defined after the label
“binary_code” in hexadecimal format. Each instruction is encoded by each .word using Little
Endian byte-order. Your MIPS program should read one .word at a time, decode the .word binary
to determine the instruction, and then print out each instruction on the Console window. Note
that some instructions in the skeleton program are not defined by the Mini-MIPS ISA. During
disassembling, your program should print out “Unsupported opcode !!“ on the console window
when encountering such instructions . Another caveat is that the Offset field encodes a signed
number, be cautious when you print them out. For jump target, simply print out the 26-bit
number.
Mini-MIPS ISA (contains only 6 instructions, you can find the same format of these
6 instructions in Appendix A of SPIM page)
0x23 rs rt offse
t
0x2b rs rt offse
t
8 rs rt imm 3
t
ar
g
e
t
0 rs rt rd 0 0x24
6 5 5 16 6 5 5 16
6 5 5 16 6 5 5 5 5 6
6 5 5 5 5 6
6 5 5 16
Load wor
d
: lw rt, offset(rs) Store wor
d
: sw rt, offset(rs)
A
d
d
immediate
addi rt, rs, imm
Jump and link
jal target
Branch on less than zero
bltz rs, offset
An
and rd, rs, rt
1 rs 0 offse
t
pf2

Partial preview of the text

Download MIPS Assembly Programming Assignment 1: Implementing a Simple Disassembler and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

ECE3055 Prof. H.-H. S. Lee

Georgia Tech Page 1 of 2

ECE3055 Fall 2006

Programming Assignment 1

MIPS Assembly Programming

Assigned: Sept 18, 2006 Signoff before: Sept 27, 2006 before class

Score: ____________ Date:___________ Name:__________________________________

TA Signoff : ________________________________________________________________

In this programming assignment, you will implement a simple disassembler program using MIPS assembly language for the Mini-MIPS ISA defined below. You will use the MIPS functional simulator  “SPIM” (http://www.ece.gatech.edu/~leehs/ECE3055 Click on Assignments -> My SPIM page) for validating the functionality of your MIPS disassembler program. Your program should disassemble and only disassemble the 6 instructions defined in our mini-MIPS ISA from the binary words provided. All other binaries not belonging to any of the 6 instructions should print out “unsupported opcode !!” First of all, you have to download the ece3055p1.s skeleton file from our course website (http://www.ece.gatech.edu/~leehs/ECE3055 click on Assignments-

Skeleton Program). This skeleton file contains 14 instructions defined after the label “binary_code” in hexadecimal format. Each instruction is encoded by each .word using Little Endian byte-order. Your MIPS program should read one .word at a time, decode the .word binary to determine the instruction, and then print out each instruction on the Console window. Note that some instructions in the skeleton program are not defined by the Mini-MIPS ISA. During disassembling, your program should print out “Unsupported opcode !!“ on the console window when encountering such instructions. Another caveat is that the Offset field encodes a signed number, be cautious when you print them out. For jump target, simply print out the 26-bit number.

Mini-MIPS ISA (contains only 6 instructions, you can find the same format of these

6 instructions in Appendix A of SPIM page)

0x23 rs rt offset 0x2b rs rt offset

8 rs rt imm 3 target

0 rs rt rd 0 0x

6 5 5 16 6 5 5 16

(^6 5 5 16 6 5 5 5 5 )

(^6 5 5 166 5 5 5 5 )

Load word : lw rt, offset(rs) Store word : sw rt, offset(rs)

Add immediate addi rt, rs, imm

Jump and link jal target

Branch on less than zero bltz rs, offset

And and rd, rs, rt 1 rs 0 offset

ECE3055 Prof. H.-H. S. Lee

Georgia Tech Page 2 of 2

Printout example on the SPIM console window:

lw $4 24($10) addi $5 $6 - unsupported opcode! and $2 $3 $ unsupported opcode! jal 120000 ...

Hint. In the skeleton file, a few ASCII (.asciiz) symbols and instruction mnemonics (e.g. bne) were defined. You can use them to print out some of the needed instruction symbols on Console window. There are many repetitive operations to carry out in your program (e.g. print dollar sign ($) before print the register number). In order to reduce the code size, you are encouraged to use procedure call, e.g. jal instruction for call and its corresponding jr $31 for return in MIPS, to handle these repetitive operations.

Tool. SPIM simulator will be used for executing your MIPS program. Visit our course website for complete information on SPIM and MIPS assembly language. For those who use PCSpim on Windows, uncheck the “load trap file” under Simulator→Settings since our skeleton file already contains _start initialization code. If you’ve never used any editor such as vi, emacs, MS visual IDE to write programs before, a free syntax-coloring editor with MIPS syntax coloring files is available at www.crimsoneditor.com.

How to receive your credit? You must go to the lab hours held by TAs for having your assignment checked off before the due time. You need to go to the right TA based on the Section you registered for. There is no need to turn in any separate document. The TA will announce sign-off sheet later for you to make an appointment for check-off. Also note that, the TA might use a different input set to perform further tests.

TA1 : Justin Fiore (justin.fiore AT gatech edu) TA2 : Nathan Parrish (nvparrish AT gatech edu)

Honor Code. This assignment must be done individually. You can discuss questions using the webct discussion board but you are not allowed to copy others’ codes. For those who violate the rule, both the originator and the copier will receive zero credit and will be immediately reported to the Dean of Students’ Affair for further action.