Docsity

MIPS Programming Assignment: Multiplying Two 8byte Numbers - Prof. A. Skavantzos, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
EE 3755 MIPS 1 Due: TBA
.
Problem 1: Write a MIPS program to multiply two 8byte numbers.
// a = {$t1,$t2}
// b = {$t3,$t4}
// c= {$s1, $s2,$s3,$s4} = a*b;
// For testing purpose give these values to registers.
// a = 0x1111123411111234.
// b = 0x1111123411111234.
8byte long number a is stored at $t1,$t2.
8byte long number b is stored at $t3,$t4.
Store the result at $s1,$s2,$s3,$s4.
1.1 Save your program on your account and name it mips1.asm.
1.2 Also submit a hard copy.
Problem 2: 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, r4
addi r1, r2,0x20
nop
beq r0, r0, LOOP
(For the problem 2.1)
2.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
What will be the offset value for LOOP.
##############################################
START:
0x400000 J LINE1
Nop
Nop
LINE1 beq r0,r0,LINE2
add r1,r0,r0
LINE2 nop
(For the problem 2.2)
2.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.
pf3

Partial preview of the text

Download MIPS Programming Assignment: Multiplying Two 8byte Numbers - Prof. A. Skavantzos and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

EE 3755 MIPS 1 Due: TBA

Problem 1: Write a MIPS program to multiply two 8byte numbers.

// a = {$t1,$t2}

// b = {$t3,$t4}

// c= {$s1, $s2,$s3,$s4} = a*b;

// For testing purpose give these values to registers.

// a = 0x1111123411111234.

// b = 0x1111123411111234.

8byte long number a is stored at $t1,$t2.

8byte long number b is stored at $t3,$t4.

Store the result at $s1,$s2,$s3,$s4.

1.1 Save your program on your account and name it mips1.asm.

1.2 Also submit a hard copy.

Problem 2 : 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, r 4 addi r1, r2,0x nop beq r0, r0, LOOP (For the problem 2 .1) 2 .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 What will be the offset value for LOOP. ############################################## START: 0x400000 J LINE Nop Nop LINE1 beq r0,r0,LINE add r1,r0,r LINE2 nop (For the problem 2 .2) 2 .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.

2 .3)Compute this branch target address: 0x400000 bne r1, r2, 3 2 .4)compute this branch target address 0x40000c bne r1,r2,- 3

Problem 3 : 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 4. 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 5 : True(right) or False(wrong) instruction.

T F

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

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

5 -3) jr $0x

5 -4) j 0x