From 85b5fde272be6ab543aa866baebabddc24566bdb Mon Sep 17 00:00:00 2001 From: cheapie Date: Sat, 23 May 2026 20:14:34 -0500 Subject: Add initial content --- c/bigfib/Makefile | 20 ++++++++++++++++++++ c/bigfib/bigfib.c | 23 +++++++++++++++++++++++ c/bigfib/bigfib.elf | Bin 0 -> 6552 bytes c/bigfib/bigfib.hex | 19 +++++++++++++++++++ c/bigfib/bigfib.o | Bin 0 -> 2184 bytes c/bigfib/rvcontroller.ld | 45 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+) create mode 100644 c/bigfib/Makefile create mode 100644 c/bigfib/bigfib.c create mode 100755 c/bigfib/bigfib.elf create mode 100644 c/bigfib/bigfib.hex create mode 100644 c/bigfib/bigfib.o create mode 100644 c/bigfib/rvcontroller.ld (limited to 'c/bigfib') diff --git a/c/bigfib/Makefile b/c/bigfib/Makefile new file mode 100644 index 0000000..6eb4ffc --- /dev/null +++ b/c/bigfib/Makefile @@ -0,0 +1,20 @@ +all: bigfib.hex + +bigfib.o: bigfib.c + clang -target riscv32-none-elf -I../rvcontroller-libraries -march=rv32imacb_zicntr_zicond_zicsr_zifencei_zihintpause_zilsd_zclsd_zabha_zacas_zbkb_zbkx_zcb_zcmp_zcmt -ffreestanding -O3 -c -o bigfib.o bigfib.c + +bigfib.elf: ../rvcontroller-libraries/rvcontroller-init.o ../rvcontroller-libraries/rvcontroller-ecalls.o bigfib.o + riscv32-none-elf-ld -T rvcontroller.ld --no-warn-rwx-segments -o bigfib.elf ../rvcontroller-libraries/rvcontroller-init.o bigfib.o ../rvcontroller-libraries/rvcontroller-ecalls.o + +dump: bigfib.elf + riscv32-none-elf-objdump -d bigfib.elf + +bigfib.hex: bigfib.elf + riscv32-none-elf-objcopy -O ihex bigfib.elf bigfib.hex + +load: bigfib.hex + bash -c "wl-copy < bigfib.hex" + +clean: + rm -f bigfib.bin bigfib.elf bigfib.o init.o + diff --git a/c/bigfib/bigfib.c b/c/bigfib/bigfib.c new file mode 100644 index 0000000..063c27e --- /dev/null +++ b/c/bigfib/bigfib.c @@ -0,0 +1,23 @@ +/* Fibonacci Sequence for RVController + * A product of Advanced Mesecons Devices, a Cheapie Systems company + * This is free and unencumbered software released into the public domain. + * See http://unlicense.org/ for more information */ + +#include +#include "rvcontroller-ecalls.h" + +uint64_t prev = 0; +uint64_t oldprev = 0; +uint64_t curr = 1; + +void main(void) { + while ((curr & 0x800000000000000) == 0 ) { + printstr("\nH "); + printint(curr/(1LL << 32)); + printstr("\nL "); + printint(curr%(1LL << 32)); + oldprev = prev; + prev = curr; + curr = prev + oldprev; + } +} diff --git a/c/bigfib/bigfib.elf b/c/bigfib/bigfib.elf new file mode 100755 index 0000000..2fcdf75 Binary files /dev/null and b/c/bigfib/bigfib.elf differ diff --git a/c/bigfib/bigfib.hex b/c/bigfib/bigfib.hex new file mode 100644 index 0000000..b13c263 --- /dev/null +++ b/c/bigfib/bigfib.hex @@ -0,0 +1,19 @@ +:10000000370101002920A94873000000828096B8BA +:1000100022E44AE003457010218939E1B70900085C +:100020001309400F130A800F930480104A85812022 +:10003000032540100D2852851D280325001025207A +:1000400003350010906088E090E4B6952A96333529 +:10005000A600B386A50033F536012330C01079D54C +:100060002264026996BE8548730000008280914830 +:10007000730000008280AD48730000008280930806 +:10008000100873000000828093085008730000007D +:10009000828093087008730000008280732510C06E +:1000A0008280732500C0828093086008730000007E +:1000B00082800589F322008093920248B3E2A20075 +:1000C00073900280828095487300000082809308BC +:1000D0000008730000008280A14873000000828045 +:1000E0009308300873000000828093084008730072 +:0C00F000000082800A4820000A4C20001A +:1001000001000000000000000000000000000000EE +:080110000000000000000000E7 +:00000001FF diff --git a/c/bigfib/bigfib.o b/c/bigfib/bigfib.o new file mode 100644 index 0000000..32d9e29 Binary files /dev/null and b/c/bigfib/bigfib.o differ diff --git a/c/bigfib/rvcontroller.ld b/c/bigfib/rvcontroller.ld new file mode 100644 index 0000000..985892b --- /dev/null +++ b/c/bigfib/rvcontroller.ld @@ -0,0 +1,45 @@ +/* Thanks https://github.com/darklife/darkriscv */ + __heap_size = 0x200; /* required amount of heap */ + __stack_size = 0x800; /* required amount of stack */ + ENTRY(_start); + MEMORY + { + RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 0x10000 + } + SECTIONS + { + .text : + { + *(.text.startup) + *(.text) + *(.text) + *(.rodata*) + } > RAM + .data : + { + *(.sbss) + *(.data) + *(.bss) + *(.rela*) + *(COMMON) + } > RAM + + .heap : + { + . = ALIGN(4); + PROVIDE ( end = . ); + _sheap = .; + . = . + __heap_size; + . = ALIGN(4); + _eheap = .; + } >RAM + + .stack : + { + . = ALIGN(4); + _estack = .; + . = . + __stack_size; + . = ALIGN(4); + _sstack = .; + } >RAM + } -- cgit v1.2.3