[libre-riscv-dev] Fwd: spike simple-v implementation, refinement needed

Luke Kenneth Casson Leighton lkcl at lkcl.net
Sat Sep 29 10:20:53 BST 2018


#include <stdio.h>

int main(int argc, char *argv[])
{
    register int x asm ("a6");
    register int y asm ("a7");
    x = 2;
    y = 2;
    register int cfg asm ("a4");
    cfg = 0x5061;
    asm volatile ("csrrwi x0,0x4f2,2");
    asm volatile ("csrrwi x0,0x4f0,2");
    asm volatile ("csrrw x0,0x4c0,%0 " : : "r"(cfg));
    asm volatile ("addi %0, %0, 5" : "=r"(x) : "r"(x));
    cfg = 0;
    asm volatile ("csrrw x0,0x4c0,%0 " : : "r"(cfg));
    printf("hello%d %d\n", x, y);
}

woo!  it actually works!  the output here is "hello7 7" not "hello7 2". woo!

l.



More information about the libre-riscv-dev mailing list