DDCA Ch6 - Part 7: RISC-V Multiplication & Division Instructions

DDCA Ch6 - Part 7: RISC-V Multiplication & Division Instructions

Risk-5 Instructions for Multiplication and Division

In this section, the video discusses Risk-5 instructions for multiplication and division, highlighting the handling of 32-bit numbers to produce 64-bit results.

Risk-5 Multiplication Instructions

  • Risk-5 multiplies two 32-bit numbers to generate a 64-bit result.
  • The instructions mull and mulh are used in Risk-5 for multiplication.
  • mulh: Stores the upper 32 bits of the product in the destination register.
  • mull: Places the lower 32 bits of the product into another register.

Example Scenario for Multiplication

  • Consider multiplying two hexadecimal numbers:
  • s1 = 40000000 (2^30)
  • s2 = 80000000 (-2^31)
  • Product: E0000000 (2^-61)

Risk-5 Division Instructions

  • When dividing two 32-bit numbers in Risk-5:
  • div: Computes quotient (s3 = s1 / s2).
  • remainder: Calculates remainder or modulo (s4 = s1 mod s2).