Can you help me with q#2.34 Activities Document Viewer Tue 21:43 1 of 2 148.73%
ID: 3746072 • Letter: C
Question
Can you help me with q#2.34
Activities Document Viewer Tue 21:43 1 of 2 148.73% add $t0, $t0, $a0 sub $a1, $al, 1 j loop addi St0, St0, 100 add SvO, St0, Szero finish 2.34 The following program tries to copy words from the address in register Sa0 to the address in register Sal, counting the number of words copied in register Sv0. The program stops copying when it finds a word equal to 0 This terminating word should be copied but not counted. There are multiple bugs in this MIPS program; fix them and turn in a bug-free version addi $v0, Szero, 0 /Initialize count //Read next word from source //Write to destination //Advance pointer to next source //Advance pointer to next destination oop sw $v1, 0(a1) addi Sa0, Sa0, 4 addi Sal, Sal, 4 beq Sv1, Szero, loop //Loop if word copied !- zero 2.49 When designing memory systems, it becomes useful to know the frequent memory reads are versus writes as well as the frequency of accesses for instructions versus data. Using the average instruction mix information for MIPS for the program SPEC2000int in Figure 2.48, find the followingExplanation / Answer
please give thumbs up, thanks
CODE:
addi $s0,$zero,COUNTER //load counter
loop: lw $v1,0($a0) //load content pointed by $a0
sw $v1, 0($a1) //store data pointed to location given in $a1
addi $a0,$a0,4 //point to next word
addi $a1,$a1,4 //point to next word
sub $s0,$s0,1 //decrement counter
bgtz $s0, loop // if counter greater than 0 then loop
j EXIT //else exit
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.