Multiplication and Division Instructions


The following table lists some multiplication and division instructions. They are with the R-type format and include:

Multiplication Division
 mul    rd, rs, rt    # rd: destination register
 mult   rs, rt        # rs: 1st source register
 multu  rs, rt        # rt: 2nd source register
 div   rd, rs, rt
 divu  rd, rs, rt

The CPU defines three 32-bit special registers: pc (program counter), hi and lo. The multiply and divide unit provides its result in hi and lo; e.g.,
   mult  $t3, $t4  # multiply 32-bit quantities in $t3 and $t4,
                   # and store 64-bit result in registers
                   # Lo and Hi: (Hi, Lo) = $t3 * $t4
   div   $t5, $t6  # Lo = $t5 / $t6 (integer quotient)
                   # Hi = $t5 mod $t6 (remainder)
To fetch the integer 32-bit product, the programmer uses move from lo (mflo). Move from hi (mfhi) is for fetching the contents of hi register of the integer 64-bit product.
mul rd, rs, rt         # 3-operand signed multiply
Computes the product of two values. This instruction puts the 32-bit product of rs and rt, or the 32-bit product of rs and the immediate value, in the destination register.
mult  rs, rt         # 2-operand signed multiply
multu rs, rt         # 2-operand unsigned multiply
Computes the 64-bit product of two (un)signed 32-bit signed values. It multiplies the contents of rs by the contents of rt and puts the result in the hi and lo registers. The multiply and divide pseudoinstructions, which make this unit appear to operate on the general registers, save the result in the hi and lo registers after the computation finishes.



      My uncle is very sick and    
      has one foot in the grave (near death).