EE 3755 Homework 5
Due: TBA
(After covering MIPS
Note1 and Note2)
Estimated
time to solve:
Prob.1
40 mins.
Prob.2 30
mins.
Prob.3 20 mins.
Prob.4 10 mins.
Prob.5 40 mins.
Prob.6 30 mins.
Prob.7 10 mins.
Total:
180 mins.
Problem 1: Answer the questions without looking
anything.(this is practice, so do not use the simulator
program although you may check the correctness of your answer)
LOOP:
0x400000 add r1,r2,r3
addi r1, r2,0x20
beq r0,r0, LOOP
(For the problem 1.1)
1.1)Write Machine code for the above 3
instructions.
(Hexadecimal format)
Hint :
opcode for add is 0 and func field is 0x20.
opcode for addi is 8 and think about rt and
rs fields.
opcode for beq is 4
What will be the offset value for LOOP.
START:
0x400000 J LINE1
nop
LINE1
beq r0,r0,LINE2
add r1,r0,r0
LINE2
nop
(For the problem1.2)
1.2)Write Machine code for the above 5
instructions.
(Hexadecimal format)
Hint :
opcode for j is 2 .
What will be the offset value for LINE1 and
LINE2.
1.3)Compute this branch target address:
0x400000
bne r1, r2,2
1.4)compute this branch target address
0x40000c
bne r1,r2,-2
Problem 2: Briefly explain about three instruction
formats for MIPS.
(Less than 20lines.
Your
answer should contain at least these following information.
a)
How big is each field at each format?
b)
Field position.
Problem 3. write
the register values after executing
following instructions.
Loop:
0x1000 |
Addi r1, r0, 3; |
R1= |
|
|
|
|
|
Addi r2, r0, 5; |
R1= |
R2= |
|
|
|
|
Sub r3, r1, r2; |
R1= |
R2= |
R3= |
|
|
|
Sub r4, r1, r2; |
R1= |
R2= |
R3= |
R4= |
R31= |
|
Beq r3, r0, loop; |
|
|
|
|
R31= |
|
ori r1, r2,
20; |
R1= |
R2= |
R3= |
|
R31= |
|
Addi r4, r0, 0x2000; |
R1= |
R2= |
R3= |
R4= |
R31= |
|
jalr r4; |
R1= |
R2= |
R3= |
R4= |
R31= |
Problem 4: True(right) or
False(wrong) instruction .
T F
4-1) addi $t0,0x1234,$t0
4-2) subi $t0,$t1,0x1234
4-3) jr $0x123456
4-4) j
0x123456789
Problem 5: Briefly explain about the register usage for
procedure call.
(Less than 20 lines, please. your answer at least should contain
explanation about v0, a0,t0,s0 registers)
Problem6: What is the MIPS assembly code for the
following C code?
//c..
# Reg Usage: j, $8;
sum, $9;
for(j = 0, j < 4;++j){
sum = sum + j;
}
Problem
7: Write real code for the following pseudo code.
7.1)li $2,
0x12345678
7.2)mul $2,
$3, $4
7.3)nop
7.4)move $1,
$2