Question

The Following source code has a stalling problem: lw $st3, 4($t0) lw $st4, 8($t0) sub $s1,...

The Following source code has a stalling problem:

lw $st3, 4($t0)

lw $st4, 8($t0)

sub $s1, $st3, $st4

sw $s1, 12($t0)

lw $t5,16($t0)

add $s2, $t3,$t5

sw $s2,20($t0)

Rearrange the code sequence that does exactly the same job without stalling:

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

Given Assembly code
lw $st3, 4($t0)

lw $st4, 8($t0)

sub $s1, $st3, $st4

sw $s1, 12($t0)

lw $t5,16($t0)

add $s2, $t3,$t5

sw $s2,20($t0)

Rearranged code
lw $t5,16($t0)

lw $st3, 4($t0)

lw $st4, 8($t0)

add $s2, $t3, $t5

sub $s1, $st3, $st4

sw $s2,20 ($t0)

sw $s1, 12($t0)

Add a comment
Know the answer?
Add Answer to:
The Following source code has a stalling problem: lw $st3, 4($t0) lw $st4, 8($t0) sub $s1,...
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
  • 1.Please use 5-stage pipeline to describe following MIPS assembly code in non-forwarding pipeline. lw         $s0,      0($t0)...

    1.Please use 5-stage pipeline to describe following MIPS assembly code in non-forwarding pipeline. lw         $s0,      0($t0) add        $s1,      $s0, $s0 mul       $s2,      $s1, $s0 . 2.Please use 5-stage pipeline to describe following MIPS assembly code in forwarding pipeline. lw         $s0,      0($t0) add        $s1,      $s0, $s0 mul       $s2,      $s1, $s0 sw         $s2,      4($t0)

  • Question 4) (12 Marks) This question is based on the MIPS assembly code shown below. data...

    Question 4) (12 Marks) This question is based on the MIPS assembly code shown below. data the Array: space 160 main: li $t6, 1 li $17, 4. sw $17, the Array($0) sw $17, theArray($17) li $t0, 8 loop: addi $t3, $t0, -8 addi $t4, $t0, -4 lw 1, the Array($t3) lw $12, the Array(St4) add $15, $t1, $t2 sw $15, theArray($to) addi $t0, $t0, 4 blt $t0, 160, loop jr Sra. Question 4 Assembly code a) what is the contents...

  • Given the following sequence of instructions: lw $s2, 0($s1) //1 lw $s1, 40($s3) //2 sub $s3,...

    Given the following sequence of instructions: lw $s2, 0($s1) //1 lw $s1, 40($s3) //2 sub $s3, $s1, $s2 //3 add $s3, $s2, $s2 //4 or $s4, $s3, $zero //5 sw $s3, 50($s1) //6 a. List the read after write (current instruction is reading certain registers which haven’t been written back yet) data dependencies. As an example , 3 on 1 ($s2) shows instruction 3 has data dependency on instruction 1 since it is reading register $s2. b. Assume the 5...

  • This problem is adapted from an earlier edition of P&H. Consider the following code used to...

    This problem is adapted from an earlier edition of P&H. Consider the following code used to implement the instruction: foo $s0,$s1,$s2 mask: .word 0xFFFFF83F start: la $t0,mask lw $t0,0($t0) la $s0,shftr lw $s0,0($s0) and $s0,$s0,$t0 andi $s2,$s2,0x1f sll $s2,$s2,6 or $s0,$s0,$s2 la $t5,shftr sw $s0,0($t5) shftr: sll $s0,$s1,0 Add meaningful comments to the code. Please explain each line and write a paragraph describing how it works. Why do you suppose that writing “self-modifying code” such as this is a bad...

  • 7 [24 marks] Consider the following MIPS code segment that is executed on a 5-stage pipeline architecture that does not implement forwarding or stalling in hardware. (1) add $4, $1, $1 (2) add $7,...

    7 [24 marks] Consider the following MIPS code segment that is executed on a 5-stage pipeline architecture that does not implement forwarding or stalling in hardware. (1) add $4, $1, $1 (2) add $7, $4, $9 (3) lw $2, 40($8) (4) sub $8, $1, $2 (5) sw $8, 80(S2) (6) sub $2, $8, $4 (7) lw S8, 2($1) (8) add $8, $4, S2 Identify the data dependences that cause hazards. You are to use the following format to inform each...

  • The pipelined MIPS datapath executes the following code: lw $16, 12($4) lw $17, 16($4) beq $8, $9...

    The pipelined MIPS datapath executes the following code: lw $16, 12($4) lw $17, 16($4) beq $8, $9, skip sw $18, 16($4) add $18, $16, $18 How many cycles does it take to execute the code if the branch is not taken?

  • a).For the following MIPS assembly code to be executed using the pipelined datapath, identify all of...

    a).For the following MIPS assembly code to be executed using the pipelined datapath, identify all of the data dependencies (which register in which instruction needs the result register value from which another instruction?) and enumerate them (give them numbers as 1,2, ...). b).Which dependencies are data hazards that will be resolved via forwarding and without a stall (you can specify the number(s) from the part a)? c).Which dependencies are data hazards that will cause a stall (you can specify the...

  • Consider the following MIPS code segment that is executed on a 5-stage pipeline architecture that does...

    Consider the following MIPS code segment that is executed on a 5-stage pipeline architecture that does not implement forwarding or stalling in hardware.    (1) add $4, $1, $1                               (2) add $7, $4, $9                               (3) lw $2, 40($8)                               (4) sub $8, $1, $2                               (5) sw $8, 80($2)                               (6) sub $2, $8, $4                               (7) lw $8, 2($1)                               (8) add $8, $4, $2 Identify the data dependences that cause hazards. You are to use the...

  • Consider the following code to be executed on a pipelined processor lw $s1, 40(Ss6) add $s6,...

    Consider the following code to be executed on a pipelined processor lw $s1, 40(Ss6) add $s6, $s2, $s2 sw Ss6, 48(Ss1) a. Include stalls/nops in the code so it executes correctly in the cases of (i) No forwarding (ii) ALU-ALU for warding, (iii) Full forwarding b. In each case calculate the number of clock cycles required to execute the code c. Assume further that the clock cycle time is 110 ps with no forwarding, 120 ps with ALU-ALU forwarding and...

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

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