diff --git a/apps/c3-hello/Makefile b/apps/c3-hello/Makefile new file mode 100644 index 0000000..f8e8fc9 --- /dev/null +++ b/apps/c3-hello/Makefile @@ -0,0 +1,34 @@ +PROJECT:=c3-hello + +DOCKER_IMAGE=riscv-dev +DOCKER_CMD:=docker run --rm -v ${PWD}../../../:/data -w /data/apps/${PROJECT} ${DOCKER_IMAGE} +PREFIX:=${DOCKER_CMD} riscv64-unknown-elf- + +CFLAGS+=-I../../common +CFLAGS+=-fno-stack-protector +CFLAGS+=-static-libgcc -fdata-sections -ffunction-sections +CFLAGS+=-g -Os -march=rv32ima_zicsr -mabi=ilp32 -static +LDFLAGS:= -T ../linker.ld -nostdlib -Wl,--gc-sections + +SRCS_C3 := $(wildcard *.c3) + +default: ${PROJECT}.bin + +${PROJECT}.a: $(SRCS_C3) + c3c --use-stdlib=no --no-entry --target elf-riscv32 static-lib $(SRCS_C3) + +crt0.o: ../crt0.s + ${PREFIX}gcc ${CFLAGS} -c -o crt0.o ../crt0.s + +#${PROJECT}.elf: ${PROJECT}.a crt0.o ../linker.ld +# ${PREFIX}ld ${LDFLAGS} -o ${PROJECT}.elf crt0.o hello.a + +${PROJECT}.elf: ${PROJECT}.a ../linker.ld + ${PREFIX}gcc -o ${PROJECT}.elf ${CFLAGS} ${LDFLAGS} ../crt0.s hello.a + +${PROJECT}.bin: ${PROJECT}.elf + $(PREFIX)objcopy ${PROJECT}.elf -O binary ${PROJECT}.bin + + +clean: + rm -f *.o *.a ${PROJECT}.elf ${PROJECT}.bin diff --git a/apps/c3-hello/hello.c3 b/apps/c3-hello/hello.c3 new file mode 100644 index 0000000..7c94f48 --- /dev/null +++ b/apps/c3-hello/hello.c3 @@ -0,0 +1,19 @@ +//static uint32_t syscall(uint32_t id, uint32_t param) { +// register uint32_t a0 asm("a0") = (uint32_t)(param); +// register uint32_t a1 asm("a1"); +// register uint32_t a7 asm("a7") = (uint32_t)(id); +// +// asm volatile ( +// "ecall" +// : "=r"(a1) // output +// : "r"(a0), "r"(a7) // input +// : "memory" +// ); +// return a1; +//} + +fn void main() @export("main") { + int x = 42; + TBD +} +