diff --git a/TP01/riscv/README.md b/TP01/riscv/README.md new file mode 100644 index 0000000..8f7332f --- /dev/null +++ b/TP01/riscv/README.md @@ -0,0 +1,8 @@ +# Installed using: + +sudo pacman -S riscv64-elf-binutils riscv64-elf-newlib riscv64-linux-gnu-gcc +yay -S riscv64-unknown-elf-gcc riscv64-unknown-elf-binutils riscv64-unknown-elf-picolibc +yay -S riscv-pk-git # which has a broken repo path, you need to manually edit PKGBUILD + +then, run using: +spike /usr/riscv64-linux-gnu/bin/pk ex1.riscv diff --git a/TP01/riscv/asshand.o b/TP01/riscv/asshand.o new file mode 100644 index 0000000..6cae7b2 Binary files /dev/null and b/TP01/riscv/asshand.o differ diff --git a/TP01/riscv/libprint.o b/TP01/riscv/libprint.o new file mode 100644 index 0000000..eaa329c Binary files /dev/null and b/TP01/riscv/libprint.o differ diff --git a/TP01/riscv/minmax.s b/TP01/riscv/minmax.s index effe800..91b2eee 100644 --- a/TP01/riscv/minmax.s +++ b/TP01/riscv/minmax.s @@ -4,7 +4,15 @@ main: addi sp,sp,-16 sd ra,8(sp) ## TODO Your assembly code there + addi t0, zero, 17 + addi t1, zero, 12 + blt t0, t1, inf + sb zero, t1, min + j end +inf: + sb zero, t2, min ## END TODO End of user assembly code +end: ld ra,8(sp) addi sp,sp,16 ret @@ -15,4 +23,4 @@ mydata: .dword 7 .dword 42 min: - .dword 0 + .dword 8 diff --git a/TP01/riscv/sum.s b/TP01/riscv/sum.s new file mode 100644 index 0000000..91f9d8f --- /dev/null +++ b/TP01/riscv/sum.s @@ -0,0 +1,19 @@ + .globl main +main: + addi sp,sp,-16 + sd ra,8(sp) + addi t0, zero, 0 + addi t1, zero, 0 + addi t2, zero, 9 +loop: + beq t1, t2, end + addi t1, t1, 1 + add t0, t0, t1 + j loop +end: + addi a0, t0, 0 + call print_int + call newline + ld ra,8(sp) + addi sp,sp,16 + ret