From ef7bd64ded846a08ec734f73b2430cb995d5be69 Mon Sep 17 00:00:00 2001 From: mpabi Date: Tue, 20 May 2025 07:49:48 +0000 Subject: [PATCH] init --- Makefile | 25 +++++++++++++++++++++++++ crt0.S | 29 +++++++++++++++++++++++++++++ main.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 Makefile create mode 100644 crt0.S create mode 100644 main.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..11fa455 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +TOP=../.. +include $(TOP)/Make.rules + + +LDLIBS= +CFLAGS+=-O0 -g + +LDFLAGS+=-Wl,--no-relax +LDFLAGS+=-Wl,-Tdata=0x80010000 + + +PROGS=prog prog.bin prog.lst + +all:: $(PROGS) + +prog: crt0.o main.o + $(LINK.c) -o $@ $^ $(LDLIBS) + $(SIZE) -A -x $@ + +clean:: + rm -f $(PROGS) *.o *.s *.lst *.bin *.srec + +.PHONY: run +run: prog.bin + ../../../src/rvddt -l0x3000 -f prog.bin diff --git a/crt0.S b/crt0.S new file mode 100644 index 0000000..61f0347 --- /dev/null +++ b/crt0.S @@ -0,0 +1,29 @@ + .text + .global _start + .type _start, @function + +_start: + + # Initialize global pointer +.option push +.option norelax + la gp,__global_pointer$ +.option pop + + # Clear the bss segment + la a0,__bss_start + la a1,__BSS_END__ + +clear_bss: + bgeu a0,a1,finish_bss + sb x0,0(a0) + addi a0,a0,1 + beq x0,x0,clear_bss +finish_bss: + + call main + + # abort execution here + ebreak + + .size _start, .-_start diff --git a/main.c b/main.c new file mode 100644 index 0000000..616e5e1 --- /dev/null +++ b/main.c @@ -0,0 +1,29 @@ +#include + +uint32_t x = 1, y =2, z[10]; +uint32_t *ip; + +char * ptr = "informatyk\0"; + +int strlen ( char *s ) { + int n; + + for (n = 0; *s != '\0'; s++) { + n++; + } + + return n; +} + +int main () { + + ip =&x; + y = *ip; + *ip = 0; + + ip = &z[0]; + + x = strlen (ptr) ; + + return 0; +}