My implementation of RISC-V interpreter that can execute commands from elf file
All commands for RISC32I are avaliable except ECALL, EBREAK and FENCE instructions
- RISC-V compiler for creating elf-file
- g++
- cmake
You need to download risc toolchain from this git repository and config fot RISC32I:
https://github.com/riscv-collab/riscv-gnu-toolchain
After many hours of clonning you need to compile program:
riscv32-unknown-elf-gcc -S program_name.c -o program_name.s
riscv32-unknown-elf-as program_name.s -o program_name.o
riscv32-unknown-elf-ld program_name.o -o program_name.out
riscv32-unknown-elf-objdump -S program_name.out > program_name.dump
You must create dump file because this interpeter parse it: project was developed on arm - no libelf for parse (in future plans)
Create dir "build" and do "cmake" and "make" in it
mkdir build
cmake ..
make all
You can find exe bin file in build/bin (Also there is logfile with dump of instructions and regs)
You must put dump_file as argument
cd build/bin
./risc file_name.dump
You can see examples: first n elememts sum and factorial in eponymous directory