Added MULH test
This commit is contained in:
parent
de202e25b9
commit
3e110a82f4
40
tests/mulh.s
Normal file
40
tests/mulh.s
Normal file
@ -0,0 +1,40 @@
|
||||
.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
|
@ -29,3 +29,4 @@ test "BLT : Branch Less Than " "../build/tests/blt " 0
|
||||
test "JAL : Jump And Link " "../build/tests/jal " 0
|
||||
test "SWLW : Store Word Load Word " "../build/tests/swlw " 0
|
||||
test "JALR : Jump And Link Register " "../build/tests/jalr " 0
|
||||
test "MULH : MULtply High " "../build/tests/mulh " 0
|
||||
|
Loading…
Reference in New Issue
Block a user