πŸ— Wiki

RISC-V

RISC-V

RISC-V (Pron. Risk-Five) is an open source instruction set of based on RISC.

1. Hello World Example

I compiled a program with simple hello-world code.

#include <stdio.h>
int main() {
  printf("Hello RISC-V!\n");
  return 0;
}

And this is its disassembly.

0000000000000668 <main>:
 668:   1141                    addi    sp,sp,-16
 66a:   e406                    sd      ra,8(sp)
 66c:   e022                    sd      s0,0(sp)
 66e:   0800                    addi    s0,sp,16
 670:   00000517                auipc   a0,0x0
 674:   02050513                addi    a0,a0,32 # 690 <_IO_stdin_used+0x8>
 678:   f29ff0ef                jal     ra,5a0 <puts@plt>
 67c:   4781                    li      a5,0
 67e:   853e                    mv      a0,a5
 680:   60a2                    ld      ra,8(sp)
 682:   6402                    ld      s0,0(sp)
 684:   0141                    addi    sp,sp,16
 686:   8082                    ret

3. See Also