Starting from:
$35

$29

CMPE 200 – Assignment 2 MIPS Instruction Set Architecture & Programming (1)


Purpose

Gain familiarity with the MIPS instruction set by assembling, simulating, and analyzing a sample MIPS program.

Tasks

        1) Install MIPSASM 2.15 (MIPS Assembler and Simulator) and MARS (MIPS Assembler and Runtime Simulator).
        2) Assemble the MIPS assembly code below (the asm file is provided) into a file called “mipstest.asm”. For each MIPS instruction, compare the machine code generated by two different assemblers.
        3) Single step through the instructions and verify contents of the relevant register(s). Record the execution results in the test log table on the next page (a Word version is provided) and note the memory value at address 80 (0x50) and 84 (0x54) after 19 instructions.
        4) Complete a lab report that contains the source code, the test log, screen captures of the appropriate execution windows, a discussion section, a collaboration section, and a conclusion section. In the discussion section, discuss your observations in the test log and try to explain them with the help of the MIPS Reference Data Card.

    • mipstest.asm

    • Test the following MIPS instructions.
    • add, sub, and, or, slt, addi, lw, sw, beq, j

#
Assembly
$0, 5
Description
=
5
Address
Machine
main:
addi $2,

# initialize $2


3000
20020005

addi $3,
$0, 12
# initialize $3
=
12
3004
2003000c

addi $7,
$3, -9
# initialize $7
=
3
3008
2067fff7

or
$4,
$7, $2
# $4 <= 3 or 5 = 7

300c
00e22025

and
$5,
$3, $4
# $5 <= 12 and 7 = 4
3010
00642824

add
$5,
$5, $4
#$5=4+7=11

3014
00a42820

beq
$5,
$7, end
# shouldn't be taken
3018
10a7000a

slt
$4,
$3, $4
#$4=12<7=
0

301c
0064202a

beq
$4,
$0, around
# should be taken

3020
10800001

addi $5,
$0, 0
# shouldn't execute
3024
20050000
around: slt
$4,
$7, $2
#$4=3<5=1
12

3028
00e2202a

add
$7,
$4, $5
#$7=1+11=


302c
00853820

sub
$7,
$7, $2
#$7=12-5=
7

3030
00e23822

sw
$7,
68($3)
#[80]=7


3034
ac670044

lw
$2,
80($0)
#$2=[80]=7


3038
8c020050

j
end
$0, 1
# should be taken

303c
08000c11
end:
addi $2,

# shouldn't execute
3040
20020001

sw
$2,
84($0)
# write adr 84 = 7

3044
ac020054

j
main

# go back to beginning
3048
08000c00



1
CMPE200 – Laboratory Assignment 2 Test Log


Configure the data segment on MARS to start at address 0 (Settings - Memory Configuration).
Assemble the given MIPS instructions on both MARS and MIPSASM. Single step through the given
MIPS instructions. Observe and record the following values in the test log table:

    • the actual machine code for both MARS and MIPSASM

    • contents of the program counter (PC) and the relevant registers for MARS

    • contents of memory at location 80 (0x50) and 84 (0x54) for MARS.


Adr
Machine Code
Machine Code
PC


Registers


Memory Content

for MARS
for MIPSASM

$v0
$v1

$a0

$a1
$a3
[80]
[84]













3000

























3004

























3008

























300c

























3010

























3014

























3018

























301c

























3020

























3024

























3028

























302c

























3030

























3034

























3038

























303c

























3040

























3044

























3048




























2

More products