Question: a. If sO is OxFFOOFFOO, how many instructions are executed? Does the number of executed instructions depend on the number of 1 's in so?

 a. If sO is OxFFOOFFOO, how many instructions are executed? Does

a. If sO is OxFFOOFFOO, how many instructions are executed? Does the number of executed instructions depend on the number of 1 's in so? Does it depend on the location of 1 's? Explain your answers. b. There are many ways to compute Hamming weight. We could test the most significant bit (bit 31 ) of so. For example, extract bit 31 with an AND instruction, and compare it with O. This is similar to the method in the code given. However, we can save one instruction. If we treat so as a 2 's complement number, so is less than 0 if and only if bit 31 in s0 is 1 . Using this method, write RISC-V instructions to compute the Hamming weight of so. Explain your method in comments. We can start with the following two instructions. How many instructions are executed if so is OxFFOOFFOO? addiadds1,t,x,x,s#s1=#makealcopysosoisnotchanged Translate the following C code to RISC-V assembly code. Assume that a,i, and r are stored in registers s1,s2, and s3, respectively. All the variables are signed. Write brief comments in your code. Clearly mark the instructions that control the loop (for example, using different colors), the instructions in if branch, and instructions in else branch. Use a minimum number of instructions. There are 12 instructions in the solutions

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!