Question

16 Points) 7. Implement the following loop using MIPS assembly instructions. Assume that r,s, and t are stored in registers $s3, $s4, and Ss5 respectively. while (sct) -s+s
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Sample Code:

.data

#add or initialize registers values here for r, s and t
#r: .word 1
#s: .word 10
#t: .word 20

.text

main:

la $s3, r    #load system call code into register $s3
la $s4, s   #load system call code into register $s4
la $s5, t   #load system call code into register $s5

syscall       #call system to print operation

Loop1: bgt $s4, $s5, EXIT #It will check whether s is greater than t s>t, if so exit or else proceed further.
   add $s3, $s3, $s4   # add r and s then assign the result to r
   add $s4, $s4, $s4   # add s with s and reassign the result to s
  
   j Loop1               # if s<t then call the loop and proceed futher or else exit.
EXIT:

Add a comment
Know the answer?
Add Answer to:
Implement the following loop using MIPS assembly instructions. Assume that r, s, and t are stored...
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
  • Given:  MIPS Programming in MIPS Assembly Language Assume: Load, Store, R-format, and Jump (j) instructions have CPI...

    Given:  MIPS Programming in MIPS Assembly Language Assume: Load, Store, R-format, and Jump (j) instructions have CPI = 1 Assume: Branch and jr or ja Instructions (e.g., branches) have CPI = 2 Assume: All MIPS system calls (e.g., for printing) have CPI = 3 Assume: Variable x stored in register $s1, y in $s2, z in $s3, i in $t0 Express the following precondition loop in MIPS assembly language x := 0 ; i := 5 ; # Document each MIPS...

  • 2. The table below holds MIPS assembly code fragments with different branch instructions LOOP addi $s2....

    2. The table below holds MIPS assembly code fragments with different branch instructions LOOP addi $s2. $s2. 2 subi $t1. st1. 1 bne t1. 0. LOOP DONE: LOOP: it st2. $0. stl beq t2. 0. DONE addi $s2. Ss2. 2 LOOP DONE: For the loops written in MIPS assembly in the above table, assume that the register Şt1 is initialized to the value of 10. What is the value in register $s2 assuming that $s2 initially has a value of...

  • IN MIPS AND MUST RUN IN QTSPIM Translate the following C code to MIPS assembly code....

    IN MIPS AND MUST RUN IN QTSPIM Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a, b, i and j are stored in registers Ss0, Ss1, St0 and Stl, respectively. Also assume that register Ss2 holds the base address of the array D. for (i=0; i<a; itt) for (i-0j<b:jt+)

  • Please answer the following questions involving MIPS assembly code: A) For the C statement below, what...

    Please answer the following questions involving MIPS assembly code: A) For the C statement below, what is the corresponding MIPS assembly code? Assume f, g are stored in S1 and S2. f = g + (-f -5) B) For the C statement below, what is the corresponding MIPS assembly code? Assume i and j are assigned in registers S1 and S2 respectively and base of address of arrays A and B are in registers S6 and S7. B[8] = A[i...

  • 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...

  • 7. Translate the following C code to MIPS assembly code. Use a minimum number of instructions....

    7. Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a,b, i and j are in registers Ss0, Ss1, St0, and St1, respectively. Also, assume that register SS2 holds the base address of the array D. for(i-0; i<a; i++) for(j=0 ; j<b; j++)

  • Problem 2 Points (40) The following problems deal with translating from C to MIPS. Assume that...

    Problem 2 Points (40) The following problems deal with translating from C to MIPS. Assume that the variables g, h, j, and j are assigned to registers Ss0, Ss1, Ss2, Ss3, and Ss4, respectively. Assume that the base address of the arrays A and B are in registers Ss6 and Ss7 respectively 1. Provide the MIPS assembly code for the above C statements. Use a minimal number of MIPS assembly instructions 2. For the C statements above, how many MIPS...

  • 1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume...

    1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume f, g, h correspond to $80, $s1, and $s2, respectively. f=g+(h-5) 2. (15 pts) For the following pseudo-MIPS assembly instructions, what is the corresponding C code? add f, g, h add f,i, f 3. (30 pts) Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the following MIPS fields: a. op = 0, rs = 18, rt=9, rd...

  • 2.4 For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the...

    2.4 For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively. sll $t0, $s0, 2               # $t0 = f * 4 add $t0, $s6, $t0         # $t0 = &A[f] sll $t1, $s1, 2               # $t1 =...

  • For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables...

    For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables i andj are assigned to registers $50 and $s1, respectively and the base address of the arrays A and B are in registers $s6 and $57, respectively. B[i] = A[B[j]+12];

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