Question

Hey, I am confused about the following MIPS questions - could you also provide an explanation...

Hey, I am confused about the following MIPS questions - could you also provide an explanation with your answer?

Thank you!

1. What is the value in $t1 when the sw instruction is executed? (i.e. what value is stored in result)

li $t1, 0

li $t2, 1

li $t3, 10

loop:

bgt $t2, $t3, end_loop

mul $t1, $t1, $t2

addi $t2, $t2, 1

j loop

end_loop:

sw $t1, result

2.

(a) If the label job is at 0x00401000, what value is contained in register $ra immediately after the execution of the jal instruction on the spim virtual machine?

0x00400200   li  $a0, 42
0x00400204   jal job
0x00400208   nop
0x0040020C   sw  $v0, x

(b) and then which of the single SPIM pseudo-instructions below are the following three instructions equivalent to:

add $t1, $0, $0
lui $t1, 0x4321
ori $t1, $t1, 0x8765

a. li $t1, 0x87654321

b.

li $t1, 0x43218765

c.

lw $t1, 0x8765

d.

addi $t1, 0x8765, 0x4321

e.

None of the other options is correct

3. Which C definition below is equivalent to the following SPIM directive?

vec: .word 1, 2, 3, 4, 5
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the answers below:::

1)

In the given code, Inside loop value is getting multiplied to t1 all the time, As t1 contains zero and mutiplication with it results zero, It will have zero all the time as result, Hence same zero will be stored to result using  sw $t1, result.

.data
result : .word 0
.text
li $t1, 0

li $t2, 1

li $t3, 10

loop:

bgt $t2, $t3, end_loop

mul $t1, $t1, $t2 #here all the time result is getting multiplied by t1, and t1 is zero.

addi $t2, $t2, 1

j loop

end_loop:

sw $t1, result

2)

jal stores the address of next instruction from where it is getting called into $ra, So as

0x00400204   jal job 

above line calling jal, The address of $ra will be  0x00400208 that is the next instruction's address.

3)

add $t1, $0, $0    #stores zero to t1
lui $t1, 0x4321    #stores 4321 at the upper 4 bits
ori $t1, $t1, 0x8765 #stores 8765 at the lower 4 bits.

Above instructions are equivalent to  

b.

li $t1, 0x43218765

4)

vec: .word 1, 2, 3, 4, 5

Above line actually creating an array,

So in c it will be like

int vec[] = {1,2,3,4,5};

Add a comment
Know the answer?
Add Answer to:
Hey, I am confused about the following MIPS questions - could you also provide an explanation...
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
  • MIPS Insertion program.........I could really use some help ASAP

    I have this MIPS program and I'm having trouble with it. This program is user inputs numbers until zero and sorts and print the numbers in order. Please soove this issue. You can use any sorting algorithm except bubble sort.  Need it as soon as possible. Here is the code:.datanum: .word 0space: .byte ' ' .text main:  # la $t0, val # loads val into a register  # li $t1, 0      #keeps track of how many numbers entered  la $a0,...

  • can someone explain how you get the answer to this question? 1. Based on the following code segment what values are in the runtime stack immediately after the fourth time the instruction labeled...

    can someone explain how you get the answer to this question? 1. Based on the following code segment what values are in the runtime stack immediately after the fourth time the instruction labeled Rec is executed .text li Sa0, 7 jai Fact #assume the address of this instruction is 2000 fother code not shown Fact: addi Ssp, Ssp, -8 sw Sra, 4(Ssp) sw Sa0, 0(Ssp) slti St0, Sa0, 1 beq St0, Szero, Rec li SvO, 1 addi $sp, Ssp, 8...

  • 5. Consider the SPIM code below. globl main .text main: ori $t1, $0, 10 ori $t2,...

    5. Consider the SPIM code below. globl main .text main: ori $t1, $0, 10 ori $t2, $0, 11 add $t3, $t1,$t2 move $t4, $t3 The following image shows a screen shot of QtSPIM page when this program is loaded, and executed in step-by step fashion. Current instruction is highlighted. Data Text x Text Regs Int Regs [16] Int Regs [16] PC = 400028 EPC 0 Cause = 0 BadAddr = 0 Status = 3000ff10 HI LO = 0 = 0...

  • im trying to complete mips program code about a calculator program that can calculate integer addition...

    im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input is given to the array of Formula char (base address $ s0) in the form of a formula. The null character (\ 0, ASCII code 0) is placed at the end. The calculation result is given to the register $ s1 and the overflow is ignored. For example,...

  • I want to calculate Y[2]=X[3]+X[4] I'm not sure that I wrote right codes. .text main ....

    I want to calculate Y[2]=X[3]+X[4] I'm not sure that I wrote right codes. .text main . la $50, x #get base address of x la $s1, y #get base address of y lw $to, 12 ($50)#get data from memory of x[3] lw $t1 , 1 6($50) #get data from memory of x[4] add $t2, $t0, $t1 sw $t2, 8($51 ) #store result to y[2] li $v0, 10 #exit program syscall data x: word 5, 1, 17,-4, 6, 3 y: .word...

  • Assignment 4 File “quad_sol.s” contains a quadratic polynomial solver, which calculates the integer solution of a quadratic polynomial equation. 1. Rewrite the program using instructions reordering to...

    Assignment 4 File “quad_sol.s” contains a quadratic polynomial solver, which calculates the integer solution of a quadratic polynomial equation. 1. Rewrite the program using instructions reordering to reduce the number of cycles needed to execute the program. Indicate the number of cycle reduction. 2. Describe how forwarding would affect the execution of the program. CODE # quad_sol.s # This assembly program calculates the integer solutions of a quadratic polynomial. # Inputs : The coefficients a,b,c of the equation a*x^2 +...

  • Please comment the MIPS code to help me understand. Here is what the code accomplishes. Here...

    Please comment the MIPS code to help me understand. Here is what the code accomplishes. Here is the code, partially commented. .data Matrix: .word 41,45,5, 34,8, 15,16,23,44,48,12,32,18,47,22,8,22 .word 46,40,42,33,13,38,27,6, 29,25,18,40,47,22,26,14,3 .word 7, 48,35,9, 43,38,9, 49,28,25,42,5, 44,10,5, 38,14 .word 46,33,16,6, 13,20,31,1, 8, 17,1, 47,28,46,14,28,7 .word 32,2, 48,25,41,29,14,39,43,46,3, 39,32,49,41,28,46 .word 5, 43,2, 48,13,4, 33,41,32,19,9, 25,30,22,2, 9, 40 .word 14,47,22,18,47,3, 35,44,18,6, 33,22,11,6, 47,50,4 .word 28,34,20,30,18,27,38,5, 26,40,37,23,16,13,37,8,7 .word 48,38,39,12,10,39,23,20,21,20,33,16,24,21,25,3,46 .word 49,38,40,38,13,47,5, 13,4, 13,23,26,12,30,29,29, 3 .word 8, 20,10,13,31,7, 12,41,12,21,28,26,43,14,35,10,19 .word 49,33,25,26,24,29,46,22,7, 5, 15,41,10,31,19,41,27 .word 48,9,...

  • 2.29 The following is the C codes and the translated MIPS codes. Assume that the C-level...

    2.29 The following is the C codes and the translated MIPS codes. Assume that the C-level integers t1 and a0 are held in register $t1 and $a0, and $s0 holds the base address of the integer MemArray. void foo () { int MemArray[100] = { 96, 98, 63, 69, 42, 27, 16, 6, 47, 74, 44, 33, 76, 7, 88, 33, 80, 86, 86, 64, 17, 67, 60, 51, 2, 61, 93, 87, 49, 98, 24, 98, 30, 65, 2,...

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

  • There is an example below Now that everything is working you can try the following exercises. To complete them you wi...

    There is an example below Now that everything is working you can try the following exercises. To complete them you will need to refer to the documentation in Appendix A The MiteASM Assembler and Appendix B The MiteFPGA Processor. Write an assembly language program for an over counter for a cricket umpire. This should 1. display a count on the 7-segment display. The count should increase by 1 when button 0 is pressed. It should reset to 0 when button...

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
Active Questions
ADVERTISEMENT