Question

In: Computer Science

1.Consider the program: .data myArray: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10...

1.Consider the program:

.data

myArray: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

.text

la $s0, myArray

li $s1, 0

loop: sll $t0, $s1, 2

add $t0, $t0, $s0

lw $s2, 0($t0)

lw $s3, 4($t0)

add $s2, $s2, $s3

sw $s2, 0($t0)

addi $s1, $s1, 1

slti $t1, $s1, 9

bne $t1, $zero, loop

.end

Explain what does this program do? How is the data bound from the .data segment to the base address register $s0? What address does Spim use for 0th element of array in $s0?

Solutions

Expert Solution

.data ;intializing section
myArray: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ;declaring the array myarray as integer one
.text ;coding section
la $s0, myArray ;copy the address of myarray into register$s0
li $s1, 0 ;loads the immediate value 0 into register $s1
loop:
sll $t0, $s1, 2 ;shift left logical that shifts the bit to left
add $t0, $t0, $s0 ;$t0=$t0+$s0
lw $s2, 0($t0) ;first array of the element is loaded at 0 which is indirect addressing
lw $s3, 4($t0) ;second array of the element is loaded at 4 which is indirect addressing
add $s2, $s2, $s3 ;add $s2=$s2+$s3
sw $s2, 0($t0) ; sets the array element to 0
addi $s1, $s1, 1 ;add immediate $s1=$s1+1
slti $t1, $s1, 9 ;if $s1 is less than immediate,$t1 is set to one or gets to zero
bne $t1, $zero, loop ;branch to the loop if $t1<>$zero
.end ;end of the loop


The base register or the segment register is used to segment the memory.The base register can beused for data access as well as program access too.Hence the data register bounds to the base register.

In SPIM for the arrays using word ,double word,quad word the data will be stored in reverse byte order in the memory.


Related Solutions

x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7...
x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7 9 7 4 6 9 9 -5.48x + 0.17 5.48x + 0.17 -0.17x + 5.48 0.17x + 5.48
Input Data Month 0 1 2 3 4 5 6 7 8 9 10 11 12...
Input Data Month 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Revenue $             -   $            -   $            -   $        -   $        -   $         -   $    2,500 $    2,875 $    3,306 $    3,802 $    4,373 $    5,028 $    5,783 $    6,650 $    7,648 $      8,795 $   10,114 $   11,631 $   13,376 $   15,382 $   17,689 $   20,343 $   23,394 $   26,903 Monthly Revenue Growth...
Input Data Month 0 1 2 3 4 5 6 7 8 9 10 11 12...
Input Data Month 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Revenue $             -   $            -   $            -   $        -   $        -   $         -   $    2,500 $    2,875 $    3,306 $    3,802 $    4,373 $    5,028 $    5,783 $    6,650 $    7,648 $      8,795 $   10,114 $   11,631 $   13,376 $   15,382 $   17,689 $   20,343 $   23,394 $   26,903 Monthly Revenue Growth...
3, 7, 8, 5, 6, 4, 9, 10, 7, 8, 6, 5 Using the previous question...
3, 7, 8, 5, 6, 4, 9, 10, 7, 8, 6, 5 Using the previous question 's scores, If three points were added to every score in this distribution, what would be the new mean? If three points were added to every score in this distribution, what would be the new standard deviation. Remember, you have already calculated population standard deviation in a previous problem. This problem requires two answers.
3 6 4 8 1 10 2 9 11 12 15 22 3 6 7 5...
3 6 4 8 1 10 2 9 11 12 15 22 3 6 7 5 8 1 12 14 Each column represents a different treatment given to sick rats. Each cell is a different rat. Use statistical analysis and use post hoc testing using contrasts to find the best treatment. Treatment 1: vitamins Treatment 2: prescription pills Treatment 3: brain surgery Treatment 4: shock therapy Treatment 5: dietary changes
Consider the following set of observations: Obs. 1 2 3 4 5 6 7 8 9...
Consider the following set of observations: Obs. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 input 1 2 3 4 5 6 7 8 9 10 11 12 13 14 result 1 2 3 5 8 13 21 34 55 89 144 233 377 610 Enter the data in L1 and L2 in your TI calculator, find the regression line, and construct a scatterplot with the regression line included. Does a line appear to...
Consider the matrix list x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. Write...
Consider the matrix list x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]. Write a list comprehension to extract the first column of the matrix [1, 4, 7]. Write another list comprehension to create a vector of twice the square of the middle column.
Using the same data… 2 3 4 4 4 6 6 6 7 8 8 9...
Using the same data… 2 3 4 4 4 6 6 6 7 8 8 9 10 10 11 12 16 16 28 46 (d) [5 pts] Determine the 5# summary. (e) Determine the lower and upper fence to determine if there are any outliers. (f) Draw and carefully label a modified boxplot for this data. (g) What is the shape of the distribution (symmetric, skewed left, or skewed right). Explain.
Year 1 2 3 4 5 6 7 8 9 10 A 1 1.01 1.0201 1.0303...
Year 1 2 3 4 5 6 7 8 9 10 A 1 1.01 1.0201 1.0303 1.0406 1.0510 1.0615 1.0721 1.0829 12.0305 B 1 .9900 .9801 .9703 .9606 .9510 .9415 .9321 .9227 10.0487 Assume a purchase price of $10 Million for both properties. (a) What is the expected total return (IRR) on a 10-year investment in each property? Use a financial calculator or equation solver for this. (b) If the 10% cap rate represents a fair market value for each...
Match No. 1 2 3 4 5 6 7 8 9 10 11 12 13 14...
Match No. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Player A 8 42 56 68 91 123 12 46 57 137 5 80 14 10 19 Player B 38 44 46 59 57 61 48 42 51 39 58 41 55 45 68 1. For the given data set representing the runs scored by two players in last 15 matches, conduct the following analysis: i. Which average you will use to summarize...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT