The same thing but in C
Find a file
Minecon724 8467142c3e
almost fix
so the issue was of course something very simple
2024-10-18 19:01:00 +02:00
include Add reading instructions (not execute yet) 2024-10-15 17:07:18 +02:00
programs almost fix 2024-10-18 19:01:00 +02:00
src almost fix 2024-10-18 19:01:00 +02:00
.gitignore initial commit 2024-10-14 19:48:56 +02:00
Makefile almost fix 2024-10-18 19:01:00 +02:00
README.txt almost fix 2024-10-18 19:01:00 +02:00
remake.sh It now runs a program 2024-10-16 15:34:06 +02:00

RISC-V (rv32i) emulator in C
This is just for me to understand how all this works, and to learn something new.
So don't use it.

Example programs:
- return.bin: returns -1094647826 (puts it to register 10)
- return2.bin: returns a different value with more steps. if it returns DADD, something's wrong

Emulator exit codes:
- <0 = OK
- 0 = never happens
- 1 - invalid opcode
- 2 - illegal instruction argument (like funct3)

To compile stuff:
0. Get the toolchain obviously
1. riscv32-unknown-elf-gcc -ffreestanding -nostdlib -nostartfiles -Wl,--no-relax -Ttext=0x0 -e main -O0 -o program.elf program.c
2. riscv32-unknown-elf-objcopy -O binary program.elf program.bin
3. program.bin is the binary file with the program, pass it as an argument

rv32i, ilp32 compatible toolchain for 64bit Linux: https://lfs.m724.eu/toolchain.tar.zst adaa74f263dcba430da588b1109bc3b90bd90a84c67b06213bd03a7bbacd1a2a
Or just the stuff necessary to make a binary file: https://lfs.m724.eu/toolchainlite.tar.zst 55e79dff7ba4093dedb8151461508fc157525ad89615d49d737845af03d1643f
Those were compiled with `./configure --prefix=$(pwd)/../toolchain --with-arch=rv32i --with-abi=ilp32` and `make`