a risc-v simulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
vriscv/tests/mulh.s

40 lines
805 B

.include "exit_return.s"
.global _start
_start:
# Set base value of a0 to 'test failed'
addi a0, zero, 1
# Multiply 2 * 3 in t0, high bits
addi t0, zero, 3
addi t1, zero, 2
mulh t0, t0, t1
addi t1, zero, 0
beq t0, t1, mulh_low_ok
exret
mulh_low_ok:
# Multiply 2<<29 * 8 in t0, high bits
# Result high should be 2
addi t1, zero, 2
slli t0, t1, 29
addi t1, zero, 8
mulh t0, t0, t1
addi t1, zero, 2
beq t0, t1, mulh_high_ok
exret
mulh_high_ok:
# Multiply 2 << 29 * -8 in t0, high bits
# Result high should be 0xFFFF_FFFE ie -2 signed ?
addi t1, zero, 2
slli t0, t1, 29
addi t1, zero, -8
mulh t0, t0, t1
addi t1, zero, -2
beq t0, t1, mulh_neg_ok
exret
mulh_neg_ok:
addi a0, zero, 0
exret