Question

In: Computer Science

Part (b): Reversing the order of bits in a word Recall that in our course we...

Part (b): Reversing the order of bits in a word

Recall that in our course we define a word to be a 32-bit sequence (i.e., four

consecutive bytes). For some algorithms it is useful to have a reversed version of

that 32-bit sequence. (The deeply curious can read a brief description about such

use in Fast Fourier Transform algorithm implementations by visiting Wikipedia at

this link: http://bit.ly/2rnvwz6 ).

Your task for part (b) is to complete the code in reverse.asm that has been

provided for you. Please read this file for more detail on what is required.

Some test cases are provided to you.

# Compute the reverse of the input bit sequence that must be stored
# in register $8, and the reverse must be in register $15.


.text
start:
        lw $8, testcase3   # STUDENTS MAY MODIFY THE TESTCASE GIVEN IN THIS LINE
        
# STUDENTS MAY MODIFY CODE BELOW
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

        nop
        add $15, $0, -10

# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# STUDENTS MAY MODIFY CODE ABOVE

exit:
        add $2, $0, 10
        syscall
        
        

.data

testcase1:
        .word   0x00200020    # reverse is 0x04000400

testcase2:
        .word   0x00300020    # reverse is 0x04000c00
        
testcase3:
        .word   0x1234fedc     # reverse is 0x3b7f2c48

Solutions

Expert Solution

Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate the question. Thank You So Much.

.text
start:
lw $8, testcase3 # STUDENTS MAY MODIFY THE TESTCASE GIVEN IN THIS LINE
  
# STUDENTS MAY MODIFY CODE BELOW
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
move $9,$8  
li $10,1 #load one
li $12,0
loop:
sll $15,$15,1 #shift left 15
and $11,$9,$10 #get first bit
or $15,$15,$11 #or the value
srl $9,$9,1#shift right 9
add $12,$12,1
blt $12,32,loop

# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# STUDENTS MAY MODIFY CODE ABOVE

exit:
add $2, $0, 10
syscall
  
  

.data

testcase1:
.word 0x00200020 # reverse is 0x04000400

testcase2:
.word 0x00300020 # reverse is 0x04000c00
  
testcase3:
.word 0x1234fedc # reverse is 0x3b7f2c48


Related Solutions

Recall that in class we defined, for any set A, P(A) := {B : B ⊆...
Recall that in class we defined, for any set A, P(A) := {B : B ⊆ A}, which we called the power set of A. a) (10) Show that, if a set A has n elements (where n ∈ {0, 1, 2, 3, 4, . . .}), P(A) has exactly 2 n elements. b) (10) Use #4(any infinite set S has a countably infinite subset) to show that, if A is an infinite set, P(A) is uncountable.
We are sending a MP3 file of 300,000 bits from Host A to Host B. Host...
We are sending a MP3 file of 300,000 bits from Host A to Host B. Host A and B are each connected to a switch S via 100 Mbps links. Assume that each link introduces a propagation delay of 10 µs (microsecond). Calculate the total transfer time of the entire file (from first bit sent to last bit received) for the following: Suppose the MP3 file is sent as one message. S is a store-and-forward device; it begins retransmitting immediately...
Part II Based on our analysis of our sample data, we are asked to perform a...
Part II Based on our analysis of our sample data, we are asked to perform a formal hypothesis test (test of significance) to examine if the average sodium content of all Jupiter Bars may actually be more than 96 milligrams. 1) Develop the correct null and alternative hypotheses using standard statistics symbols, using words, or using both. 2) Based on the context of the question we are investigating and the nature of our sample data: a) Determine if using a...
Part B only: Two types of drill bits are being tested for wear. The two types...
Part B only: Two types of drill bits are being tested for wear. The two types of drill bits are each tested on 10 different machines, each used for a variety of parts. The data on wear in mm, over a 2-week testing cycle is shown below. Drill Bit Machine 1 2 1 3.2 2.1 2 3.0 2.4 3 2.4 2.2 4 1.4 1.3 5 3.4 2.8 6 2.0 1.9 7 2.8 2.2 8 3.5 2.5 9 3.1 2.2 10...
A theme throughout our course has been Phenotype because Protein. As we consider these examples we...
A theme throughout our course has been Phenotype because Protein. As we consider these examples we need to understand what the phenotype/product is, how a protein is responsible for it and what specifically is the protein targeted with the technology. So, what is the molecular product of golden rice? What is the protein targeted for this technology? 7-10 sentences.
: Recall the airplane cargo problem we have discussed in our first lecture. An air-freight company...
: Recall the airplane cargo problem we have discussed in our first lecture. An air-freight company has 8 adjacent positions on its Boeing-727 aircraft for freight containers. The weights of this containers depend on what they are carrying. and company statistics indicate that %7 of the containers are classified as ”heavy”. While heavy containers are not inherently dangerous, having two such containers next to each other is considered dangerous should the plane encounter a wind gust. Understandably, company wants to...
In our course materials for week three, we delved into Corporations and Stocks. Take a moment...
In our course materials for week three, we delved into Corporations and Stocks. Take a moment and review the concepts Authorized Stocks, Issued Stocks and Outstanding Stocks. Discuss the relevance of each of these and provide an example of each. Feel free to use a "real" company like Apple or Netflix to discuss their stock history and current status.
Recall the airplane cargo problem we have discussed in our first lecture. An air-freight company has...
Recall the airplane cargo problem we have discussed in our first lecture. An air-freight company has 8 adjacent positions on its Boeing-727 aircraft for freight containers. The weights of this containers depend on what they are carrying. and company statistics indicate that %7 of the containers are classified as ”heavy”. While heavy containers are not inherently dangerous, having two such containers next to each other is considered dangerous should the plane encounter a wind gust. Understandably, company wants to know...
As we wrap up our course in principle of managerial accounting, I would like you to...
As we wrap up our course in principle of managerial accounting, I would like you to discuss how this class could be relevant to your future professional careers. Many of you won't become professional accountants, but there are many concepts that you could see again in your careers. Please take a minimum of 2 paragraphs and discuss at least 2 significant concepts that you have learned that not only caught your attention, but also could be very valuable to take...
Throughout this course, we have tried to emphasize the importance of meeting our nutritional needs through...
Throughout this course, we have tried to emphasize the importance of meeting our nutritional needs through healthy food choices. This question asks you to put your knowledge to work and show what you know about our requirements for protein.    a. John is a healthy 6 ft., 200 lb male, whose recommended caloric intake is 2000 calories a day. He is in a sedentary job, but goes to a personal trainer twice a week. The trainer has recommended that he...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT