Skip to content

Commit fe3962b

Browse files
Samir-Rashidatar13trdavidt
authored
Implement RISCV Translation (#5)
* instruction: split arm, riscv opcodes and add registers * translate: add minimal riscv translation map * meta: rename `test/` -> `tests/` * test imports * instruction: specify arguments to RISC-V ops * wip translations * map_val empty * more translations + builds now * test: run translation from RISCV to ARM enums * map_register use helpers * update calls to map_register with widths * fix move of width values * map width * translate: `map_register_name` with semantic meanings Corrected the translation between registers for our 64 bit architectures. * map width * starting instruction encoding * have assembly output now * patched and assembled aarch64 add * fix patched add example * fixed width/segfault issues * call syscall * merge and working print * print and echo tests * basic control flow * fix count to 5 test * meta: add final documentation * tests badge --------- Co-authored-by: Anthony Tarbinian <atar137h@gmail.com> Co-authored-by: David Tran <tr.davidt@gmail.com>
1 parent 7577fe8 commit fe3962b

31 files changed

+1744
-196
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ Cargo.lock
2626

2727
# temporary files
2828
*.bin
29+
30+
.vscode/

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
# binary-room
2+
3+
[![Tests](https://github.com/Samir-Rashid/binary-room/actions/workflows/cargo_test.yml/badge.svg)](https://github.com/Samir-Rashid/binary-room/actions/workflows/cargo_test.yml)
4+
25
Binary translator from RISC-V to ARM written in Rust
6+
7+
8+
## Testing
9+
10+
To get all the cross-compiling dependencies, enter the nix shell using `nix develop`.
11+
12+
`cargo test -- --nocapture`
13+
14+
Then run `./run.sh filename` to assemble and run the file.

flake.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# dual cross compile toolchain
2+
# https://github.com/noteed/riscv-hello-asm/blob/main/shell.nix
13
{
24
description = "binary-room";
35

@@ -35,6 +37,8 @@
3537
];
3638
packages = with pkgs; [
3739
rust-analyzer-nightly
40+
clang-tools
41+
hyperfine # benchmarking tool
3842
];
3943
};
4044
}

run.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
ASM_FILE=$1
4+
5+
6+
aarch64-linux-gnu-as $ASM_FILE -o $ASM_FILE.as
7+
aarch64-linux-gnu-ld $ASM_FILE.as -o $ASM_FILE.bin
8+
./$ASM_FILE.bin
9+
echo $?

0 commit comments

Comments
 (0)