MIPS Assembly Program: Instruction Execution and Formats - Prof. A. Skavantzos, Assignments of Electrical and Electronics Engineering

Machine code instructions and explanations for various mips assembly language operations, including loops, branches, and register usage for procedure calls. It also includes problems to solve for understanding the concepts of instruction formats and register values.

Typology: Assignments

Pre 2010

Uploaded on 08/31/2009

koofers-user-2ve
koofers-user-2ve 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
EE 3755 MIPS 1 Due: TBA
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 $t1, $t2, $t4
addi $t1, $t2,0x20
nop
beq $s0, $s1, LOOP
(For the problem 1.1)
1.1)Write Machine code for the above 4 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
register number for $t0 is 8
register number for $s0 is 16
What will be the offset value for LOOP when we are using delayed branch?
What will be the offset value for Loop when we are using non delayed branch?
##############################################
START:
0x400000 J LINE1
Nop
Nop
LINE1 beq $s0,$s1,LINE2
add $s1,$s2,$s3
LINE2 nop
(For the problem 1.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, 3
1.4)compute this branch target address
0x40000c bne r1,r2,-3
pf3

Partial preview of the text

Download MIPS Assembly Program: Instruction Execution and Formats - Prof. A. Skavantzos and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EE 3755 MIPS 1 Due: TBA

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 $t1, $t2, $t addi $t1, $t2,0x nop beq $s0, $s1, LOOP (For the problem 1 .1) 1 .1)Write Machine code for the above 4 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 register number for $t0 is 8 register number for $s0 is 16 What will be the offset value for LOOP when we are using delayed branch? What will be the offset value for Loop when we are using non delayed branch? ############################################## START: 0x400000 J LINE Nop Nop LINE1 beq $s0,$s1,LINE add $s1,$s2,$s LINE2 nop (For the problem 1 .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, 3 1 .4)compute this branch target address 0x40000c bne r1,r2,- 3

Problem 2 : Briefly explain about three instruction formats for MIPS.

(Less than 20lines.

Your answer should contain at least these following information.

a) a) How big is each field at each format?

b) 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 r 4 , r1, r2; R1= R2= R3= R4= R31=

Beq r3, r0,

loop;

R31=

ori r1, r2, 20; R1= R2= R3= R31=

Addi r 4 , r0,

0x2000;

R1= R2= R3= R4= R31=

jalr r 4 ; R1= R2= R3= R4= R31=

Problem 4 : True(right) or False(wrong) instruction.

T F

4 -1) addi $t0,0x1234,$t

4 -2) subi $t0,$t1,0x

4 -3) jr $0x

4 -4) j 0x

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,s

registers)

Problem 6:

6-1)Write MIPS programs for the following c programs ,

.. # REGISTER USAGE ..SUM , $s0, i, $t0,