This commit is contained in:
mpabi 2025-05-20 07:49:48 +00:00
commit ef7bd64ded
3 changed files with 83 additions and 0 deletions

25
Makefile Normal file
View File

@ -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

29
crt0.S Normal file
View File

@ -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

29
main.c Normal file
View File

@ -0,0 +1,29 @@
#include <stdint.h>
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;
}