Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started