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/squares/Makefile | 20 ++++++ c/squares/rvcontroller.ld | 45 ++++++++++++ c/squares/squares.b | 8 +++ c/squares/squares.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++ c/squares/squares.elf | Bin 0 -> 6752 bytes c/squares/squares.hex | 42 ++++++++++++ c/squares/squares.o | Bin 0 -> 2336 bytes 7 files changed, 284 insertions(+) create mode 100644 c/squares/Makefile create mode 100644 c/squares/rvcontroller.ld create mode 100644 c/squares/squares.b create mode 100644 c/squares/squares.c create mode 100755 c/squares/squares.elf create mode 100644 c/squares/squares.hex create mode 100644 c/squares/squares.o (limited to 'c/squares') diff --git a/c/squares/Makefile b/c/squares/Makefile new file mode 100644 index 0000000..f957bfa --- /dev/null +++ b/c/squares/Makefile @@ -0,0 +1,20 @@ +all: squares.hex + +squares.o: squares.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 squares.o squares.c + +squares.elf: ../rvcontroller-libraries/rvcontroller-init.o ../rvcontroller-libraries/rvcontroller-ecalls.o squares.o + riscv32-none-elf-ld -T rvcontroller.ld --no-warn-rwx-segments -o squares.elf ../rvcontroller-libraries/rvcontroller-init.o squares.o ../rvcontroller-libraries/rvcontroller-ecalls.o + +dump: squares.elf + riscv32-none-elf-objdump -d squares.elf + +squares.hex: squares.elf + riscv32-none-elf-objcopy -O ihex squares.elf squares.hex + +load: squares.hex + bash -c "wl-copy < squares.hex" + +clean: + rm -f squares.bin squares.elf squares.o init.o + diff --git a/c/squares/rvcontroller.ld b/c/squares/rvcontroller.ld new file mode 100644 index 0000000..985892b --- /dev/null +++ b/c/squares/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 + } diff --git a/c/squares/squares.b b/c/squares/squares.b new file mode 100644 index 0000000..b235485 --- /dev/null +++ b/c/squares/squares.b @@ -0,0 +1,8 @@ +++++[>+++++<-]>[<+++++>-]+<+[ + >[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+ + >>>+[[-]++++++>>>]<<<[[<++++++++<++>>-]+<.<[>----<-]<] + <<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<]]<[>+<-]>]<<-]<<- +] +[Outputs square numbers from 0 to 10000. +Daniel B Cristofani (cristofdathevanetdotcom) +http://www.hevanet.com/cristofd/brainfuck/] diff --git a/c/squares/squares.c b/c/squares/squares.c new file mode 100644 index 0000000..435ddff --- /dev/null +++ b/c/squares/squares.c @@ -0,0 +1,169 @@ +/* This is a translation of squares.b, generated by bftoc.py (by Paul Kaefer) + * It was generated on Friday, May 15, 2026 at 07:20PM + */ + +#include "rvcontroller-ecalls.h" + +void main(void) +{ + int size = 1000; + int tape[size]; + int i = 0; + + /* Clearing the tape (array) */ + for (i=0; i