DDCA Ch6 - Part 21: Signed and Unsigned RISC-V Instructions
Introduction
In this section, the speaker introduces the topic of signed and unsigned instructions in RISC-V architecture, highlighting the differences between them and their impact on operations like multiplication.
Signed vs. Unsigned Instructions
- Signed and unsigned instructions in RISC-V cater to different flavors of operations and overflow detection.
- The speaker explains how signed (mole h) and unsigned (mole h u, mole h s u) multiplication instructions treat operands differently.
- Interpretation of numbers as signed or unsigned affects the outcome of operations.
- Example provided where interpreting numbers differently leads to varied results in multiplication.
- Branches and comparisons have both signed and unsigned versions.
- Discussion on branches interpreting numbers as signed two's complement or in an unsigned manner.
Overflow Detection
This part delves into detecting overflow in both signed and unsigned scenarios within RISC-V architecture.
Detecting Overflow
- Unsigned overflow detection relies on comparing the result with input numbers.
- If the result is smaller than either input number, overflow has occurred.
- Signed overflow detection involves using comparison instructions like set less than.
- Comparing results with inputs helps identify if overflow took place based on sign differences.
- Branching can be used to determine correctness post-operation.