init
This commit is contained in:
commit
ef7bd64ded
25
Makefile
Normal file
25
Makefile
Normal 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
29
crt0.S
Normal 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
29
main.c
Normal 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;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user