Question: Program in RISC - V . Please ensure the code works in the venus web terminal. In the venus web terminal, sys call code for

Program in RISC-V. Please ensure the code works in the venus web terminal. In the venus web terminal, sys call code for printing is 1.For printing in hex, it's 34.
Strategy:
1. Check if the addition produces an overflow
a. Overflow just happens when a and b have the same polarity. You can use SLU to set two rds by comparing a to 0 and b to 0. Xor two rds. If they are the same, the xor should return a 0, meaning a and b have the same polarity.
b. If the sum does not have the same polarity with a and b, then overflow occurs.
2. Once overflows, the sum will be wrong. We need to convert it to a right hex representation in 2s complement.
a. If the wrong sum is +ve, extend 32 bits of 1s and put them into an extra register to make the sum as 32bits +32 bits long.
b. If the wrong sum is in -ve, extend 31 bits of 0s and 1 bit of 1 and put them into an extra register. The highest bit of the sum register should be turned to 0. These two registers make the sum as 32bits +32bits long.
3. Print both of the two registers in hex
Program in RISC - V . Please ensure the code

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 Accounting Questions!