An RV32IMF implementation w/ migen/LiteX
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.
 
 
 
Risq5/software/source/testmultiply.c

47 lines
1.5 KiB

#pragma GCC diagnostic ignored "-Wunused-function"
static void start(void)
{
__asm__ __volatile__ ("\
auipc ra,0 # Store current pc \n\
lui sp,%hi(0x40192000) # Setup stack pointer \n\
addi sp,sp,%lo(0x40192000) # s.a. \n\
csrr t0,misa # Verify ISA: M-extension avail \n\
lui t1,0x40001 # M extension bit \n\
addi t1,t1,0x100 # & I base extension bit \n\
bne t0,t1,not_avail # exit \n\
lui t0,0xFFFFF # 0xffffffff * 0xffffffff \n\
ori t0,t0,-1 # \n\
mv t1,t0 # both are negative \n\
mulh t2,t0,t1 # => FFFFFFFE/00000001 \n\
mulhsu t2,t0,t1 # \n\
mulhu t2,t0,t1 # \n\
mul t2,t0,t1 # \n\
nop # \n\
lui t1,0x0 # 0xffffffff * 2 \n\
addi t1,t1,2 # \n\
mulh t2,t0,t1 # => 0x00000001/FFFFFFFE \n\
mulhsu t2,t0,t1 # \n\
mulhu t2,t0,t1 # \n\
mul t2,t0,t1 # \n\
nop # \n\
li t0,0x123 # x = 123 * 2 \n\
li t1,0x2 # ... \n\
mul t2,t0,t1 # => 246 (F6h) \n\
nop # \n\
li t0,-30 # x = -30 * 5 \n\
li t1,5 # ... \n\
mul t2,t0,t1 # => -150 \n\
nop # \n\
li t0,-30 # x = -30 * -5 \n\
li t1,-5 # ... \n\
mul t2,t0,t1 # => 150 (96h) \n\
not_avail: nop # ... \n\
");
#include "onek_nops.c"
#include "onek_nops.c"
#include "onek_nops.c"
#include "onek_nops.c"
}