Question

In: Computer Science

.text .globl main main:       lui $8, _______ # the address of pairs (SPIM:0x1000; Mars:0x1001)...

.text
.globl main

main:   
   lui $8, _______ # the address of pairs (SPIM:0x1000; Mars:0x1001)
   lw $9, 0(_____) # get the number of pairs (6) and store in $9
   ori $10, $0, 0 # use $10 to store the height sum
   ori $11, $0, 0 # use $11 to store the weight sum
   ori $12, $0, 0 # use $12 to count
   ori $13, $0, 0 # use $13 to store temp values;
addiu $8, $8, ___ # increase the address to get the first pair;
loop: ___________________ # jump to compute the average if count==number of pairs
   ____ $13, ____ # get height and store in $13
   add ___________ # update the height sum using $10
   addiu $8, $8, ___ # increase the address
   ____ $13, ____ # get weight and store in $13
   add ___________ # update the weight sum using $11
   addiu $8, $8, ___ # increase the address
   add ___________ # increase count
   j loop

ave:    div ________ # compute the average of height
   ___ $10 # store the height average in $10
   div ________ # compute the average of weight
   ___ $11 # store the weight average in $11
      
.data
pairs: .word 6 # number of pairs
.word 30, 60 # first pair: height, weight
.word 65, 51
.word 27, 67
.word 68, 270
.word 62, 115
.word 42, 43

## End of file

Solutions

Expert Solution

MIPS PROGRAM :-

.text
.globl main

main:   
lui $8, 0x1000 # the address of pairs (SPIM:0x1000; Mars:0x1001)
lw $9, 0($8) # get the number of pairs (6) and store in $9
ori $10, $0, 0 # use $10 to store the height sum
ori $11, $0, 0 # use $11 to store the weight sum
ori $12, $0, 0 # use $12 to count
ori $13, $0, 0 # use $13 to store temp values;
addiu $8, $8, 4 # increase the address to get the first pair;
loop: beq $9, $12, ave # jump to compute the average if count==number of pairs
lw $13, 0($8) # get height and store in $13
add $10, $10, $13 # update the height sum using $10
addiu $8, $8, 4 # increase the address
lw $13, 0($8) # get weight and store in $13
add $11, $11, $13 # update the weight sum using $11
addiu $8, $8, 4 # increase the address
addiu $12, $12, 1 # increase count
j loop

ave: div $10, $12 # compute the average of height
mflo $10 # store the height average in $10
div $11, $12 # compute the average of weight
mflo $11 # store the weight average in $11
  
.data
pairs: .word 6 # number of pairs
.word 30, 60 # first pair: height, weight
.word 65, 51
.word 27, 67
.word 68, 270
.word 62, 115
.word 42, 43

## End of file


Related Solutions

If A is a 32-bit address, typically an instruction sequence such as: lui x19, A_upper addi...
If A is a 32-bit address, typically an instruction sequence such as: lui x19, A_upper addi x19, x19, A_lower can be used to load the word at A into a register (in this case x19). a) How many bits of A are in A_upper? b) If the MSB of A_upper is 1, what would be the value of the leftmost 32-bits of register x19. Provide your answer in decimal. c) After the lui instruction, the rightmost 12-bits of x19 would...
Jack packs 3 pairs of shoes, 4 pairs of boots, 6 pairs of jeans, 8 pairs...
Jack packs 3 pairs of shoes, 4 pairs of boots, 6 pairs of jeans, 8 pairs of dress pants, and 2 dress shirts for a trip. a.) How many different outfits can Jack make with these items? b.) If Jack were to bring along 2 sweaters so that he could wear either a dress shirt or a sweater or he could wear both a dress shirt and a sweater, how many outfits could Jack make?
What was the main message of the Gettysburg Address?
What was the main message of the Gettysburg Address?
Allow the main process to generate a text file containing the text of this assignment. The...
Allow the main process to generate a text file containing the text of this assignment. The main process will then create two other processes and pass to them the name of the file and two codes (code1 and code2) using a pipe() system call. The codes are two different alphabetic letters such as “a” and “k”. The child processes should search the file for the character in the interval received, compute their frequencies and return them through a separate pipe...
JavaScript Find and Replace Text Main text: a text area with 3 rows and 20 columns....
JavaScript Find and Replace Text Main text: a text area with 3 rows and 20 columns. The default text is “Hello testing”. The text area cannot be empty. • Find text: a text box for the user to key in text he/she wants to find. • Replacement text: a text box for the user to key in the replacement text. If the find text is empty, this element should be disabled (i.e. user cannot key in anything here). • Find...
Travel to Mars is high up on NASA’s long-term agenda. One of the main issues will...
Travel to Mars is high up on NASA’s long-term agenda. One of the main issues will be the travel time, which is considerably longer than travel to the Moon. Estimate the travel time to Mars in months adopting a distance of 193 million kilometres between Mars and Earth. Hint: suppose a Hohmann transfer orbit were used with a configuration in which Earth and Mars are on opposite sides of the Sun.
Are the number of lone pairs of electrons on the central atoms the main factor that's...
Are the number of lone pairs of electrons on the central atoms the main factor that's used to determine the molecular shape or geometry?
skills drill 8:1 requisition activity(text fig.8-2)
skills drill 8:1 requisition activity(text fig.8-2)
Use the SWOT management tool from your text to address a general analysis of the opioid...
Use the SWOT management tool from your text to address a general analysis of the opioid crisis in Anytown.
Address the following: The text describes several fiscal policy options to stabilize the economy: Changes in...
Address the following: The text describes several fiscal policy options to stabilize the economy: Changes in Government Purchases, Business Taxes, Income Taxes, and Transfer Payments. Based on what you’ve learned so far in the course, determine if Italy currently needs economic stimulus or contraction. Describe how each policy option could specifically be used to change the national economy. Example: Country Z needs economic stimulus. The government could lower the business tax on buying new equipment. This would stimulate the economy...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT