Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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?

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe why being ethical is not easy.

Answered: 1 week ago