Пример #1
0
def execute_mulhu( s, inst ):
  a, b = s.rf[inst.rs1], s.rf[inst.rs2]

  multhi = multhi64( a, b )

  s.rf[ inst.rd ] = sext_xlen( multhi )
  s.pc += 4
Пример #2
0
def execute_mulhsu( s, inst ):
  a, b = s.rf[inst.rs1], s.rf[inst.rs2]
  a_s = signed(a, 64)
  a = abs(a_s)

  multlo = trim_64( a * b )
  multhi = multhi64( a, b )

  # negate -- taken from
  # http://stackoverflow.com/questions/1541426/computing-high-64-bits-of-a-64x64-int-product-in-c
  # this requires us to do low multiplication as well, so it's probably
  # not very efficient
  if a_s < 0:
    multhi = ~multhi
    if multlo == 0:
      multhi += 1

  s.rf[ inst.rd ] = sext_xlen( multhi )
  s.pc += 4