Question

Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of...

Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of MIPS instructions to accomplish the required computation.
(8 Points)

1) bgt $t1, 100, Label # bgt means branch if greater than 2) ble $s2, 10, Next # ble means branch if less than or equal 3) ror $s0, $s4, 7 # ror means rotate right $s4 by 7 bits and store the result in $s0 4) neg $s5, $s4 # $s5 will have the negative value of $s4

[B] Consider the following high-level piece of code: (8 Points)
if ((a > b) || (b > c)) then
{d = 1;}
1) Translate the above code into MIPS assembly instructions assuming that variables a, b, c, and d are stored in the following registers $s0, $s1, $s2, and $s3, respectively. Also, assume that only signed 32-bit integers are used.

2) Now, translate the above code into MIPS assembly instructions assuming that the addresses of the variables a, b, c, and d are stored in the following registers $s0, $s1, $s2, and $s3, respectively. Also, assume that only signed 32-bit integers are used.



  
4

Question 2 (14 Points)
[A] Suppose that you are requested to improve the MIPS architecture by increasing the number of registers from 32 to 64 registers. Do you think that this would be possible? Justify your answer. If your answer is “yes”, show how you will do it. (Full credit will be given for the detailed and perfect answer). (4 Points)

[B] Covert the following machine language codes into their corresponding MIPS assembly language instructions. Express the immediate values in decimal. (Show all your steps and calculations to get full credit) (6 Points)

Machine code1: 00110001000100011000011101100101
Machine code2: 00000000000010010100101010000000
Machine code3: 10001101000010010000000000000000
Machine code4: 00000010110000000000000000001000

[C] Consider an array B with size “n”. Assume that the array’s base address is stored in register $s0 and its size “n” is stored in register $s1. Write the MIPS assembly instructions for the following fragment of high-level code: (4 Points)
k=0;
for (j=0; j < n -1 ; j++)   
if ( B[j]==B[j+1]) then k++;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. bgt $t1, 100, Label # bgt means branch if greater than

Equivalent MIPS code

slti $at,$t1,100

beq $at,$0,Label

2. ble $s2, 10, Next # ble means branch if less than or equal

beq $s2,10,Next

slti $at,$s2,10

bneq $at,$0,Next

3. ror $s0, $s4, 7 # ror means rotate right $s4 by 7 bits and store the result in $s0

srl $t0,$s4,7

sll $t1,$s4,25

or $s0,$t0,$t1

4. neg $s5, $s4 # $s5 will have the negative value of $s4

sub $s5,$zero,$s4

B)

if ((a > b) || (b > c)) then
{d = 1;}

a=s0

b=s1

c=s2

d=s3

slt $at,$s1,$s0

bneq $at,$0,L1

slt $at,$s2,$s1

bneq $at,$0,L1

L1: li $s3,1

Add a comment
Know the answer?
Add Answer to:
Translate each of the following pseudo-instructions into MIPS instructions. You should Produce a minimal sequence of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT