1-(2 points) For the following C statement, what is the corresponding RISC-V assembly code? Assume that...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1-(2 points) For the following C statement, what is the corresponding RISC-V assembly code? Assume that the variables x, y, h, and i are given and could be considered integers as declared in a C program. Use a minimal number of assembly instructions. Also, use the variables as opposed to register values. Hint: keep in mind we don't have a "subi" instruction. h = (x - y) + (i-1) 2-(2 points) For the following RISC-V assembly instructions below, what is a single corresponding C statement? Assume f, g, h, i are in x18, x19, x20 and x21. Your answer must be one single C statement for all assembly instructions as opposed to one C statement for each assembly instruction. add x18, x19, x20 sub x18, x18, x21 3-Registers in RISC-V are 64-bit. For the sake of simplicity, consider the following instructions operating on 32-bit registers. Assume that registers x5 and x6 hold the values 0xBBBBBBBB and 0x00000000, respectively. (2 points) - What is the value in x6 for the following slli x6, x5, 6 (2 points) - Using the result from the part above, what is the value in x6 for the following instruction. srli x6, x6, 6 4- Consider the following RISC-V assembly instructions: addi x11, x0, 11 addi x2, x0, 1 addi x3, x0, 2 Loop: mul x2, x2, x3 addi x11, x11, -1 bne x11, x0, Loop (2 points) - How many iterations of the loop are performed? (2 points) - What is the value in x2 when this program terminates? 5-(3 points) - Provide the format and assembly language instruction for the following hex values: Address 1000: 13 Address 1001:03 Address 1002: C5 Address 1003: 00 Hint: first consider big-endian vs. little-endian as you convert to binary. Then, divide the bits up into the appropriate fields, decipher the opcode, and so on. 1-(2 points) For the following C statement, what is the corresponding RISC-V assembly code? Assume that the variables x, y, h, and i are given and could be considered integers as declared in a C program. Use a minimal number of assembly instructions. Also, use the variables as opposed to register values. Hint: keep in mind we don't have a "subi" instruction. h = (x - y) + (i-1) 2-(2 points) For the following RISC-V assembly instructions below, what is a single corresponding C statement? Assume f, g, h, i are in x18, x19, x20 and x21. Your answer must be one single C statement for all assembly instructions as opposed to one C statement for each assembly instruction. add x18, x19, x20 sub x18, x18, x21 3-Registers in RISC-V are 64-bit. For the sake of simplicity, consider the following instructions operating on 32-bit registers. Assume that registers x5 and x6 hold the values 0xBBBBBBBB and 0x00000000, respectively. (2 points) - What is the value in x6 for the following slli x6, x5, 6 (2 points) - Using the result from the part above, what is the value in x6 for the following instruction. srli x6, x6, 6 4- Consider the following RISC-V assembly instructions: addi x11, x0, 11 addi x2, x0, 1 addi x3, x0, 2 Loop: mul x2, x2, x3 addi x11, x11, -1 bne x11, x0, Loop (2 points) - How many iterations of the loop are performed? (2 points) - What is the value in x2 when this program terminates? 5-(3 points) - Provide the format and assembly language instruction for the following hex values: Address 1000: 13 Address 1001:03 Address 1002: C5 Address 1003: 00 Hint: first consider big-endian vs. little-endian as you convert to binary. Then, divide the bits up into the appropriate fields, decipher the opcode, and so on.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Find the dy/dx for the following 3 2x+1.2x+1 (x +1)4 1- y=-
-
In general terms, what application areas are supported by Bluetooth?
-
The following items were selected from among the transactions completed by Sherwood Co. during the current year: Mar. Apr. Jun. Jul. Aug. Dec. 1 Purchased merchandise on account from Kirkwood Co.,...
-
The engine is working on ideal Otto cycle. The temperature at the beginning and at the end of compression is \(60^{\circ} \mathrm{C}\) and \(400^{\circ} \mathrm{C}\). Calculate the air standard...
-
Smith & Co., a local Dallas public accounting firm, is incorporated as a professional corporation, with three shareholders, all CPAs. The shareholders have developed a combination of marketing,...
-
How fast would 1 kg bowling ball travel if it had same kinetic energy as that of the elephant provided the mass of the elephant is 600kg and velocity is 10m/s?
-
The famous corporate fraud would be waste management; Inc. is a comprehensive waste company that was founded in 1894 in North America by Larry Beck. The company itself had many fraudulent crimes with...
-
Your design specifications must meet the following Requirements: 1. Arrays 2. Methods with parameters 3. Input or output files 4. GUI or menu I don't really know where to start.... I'm in an Intro...
-
When tasked with ventilation a fire fighter has numerous considerations to take into account before performing the task. List and defend 5 considerations that you take into account if and when...
-
Target's year end 12/31/2020 inventory records indicated a balance of $678,000. Additional information indicates that this amount also included the following inventory items: Purchases: (Target...
-
If the Ad agency is currently producing 12 proposals and 15 ads, what is the opportunity cost of producing 22 proposals? (number of ads)
-
Consider the function U (p,b) = 2ln (p) + In (b) (a) Find the unconstrained maximum of the function (b) Now, suppose that the maximization is subject to the constraint 2p+36=24. What is the...
-
Multiple Choice Questions: 1) Which of the following is the last step in developing an activity-based costing system? A) Estimate the total quantity of the cost driver B) Estimate the total indirect...
-
Use the method of Example 4.29 to compute the indicated power of the matrix. 1 0 1
-
A company with a price-earnings ratio of 14 has an earnings yield closest to: A. 7.14% B. 14.00% C. 92.86%
-
Which of the following is not produced by a company to communicate its financial results? A. Schedule 13D. B. Annual report. C. 10-K statement.
-
The role of the 8-K filing with the Securities and Exchange Commission is best described as to disclose: A. the annual report. B. executive compensation. C. holdings of beneficial owners.
Study smarter with the SolutionInn App