From: Robin Krens Date: Mon, 8 Jul 2019 13:39:02 +0000 (+0800) Subject: jump to c X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=0c7ff283cb17c203da9a98fbd82ed87aa75abe52;p=cortex-from-scratch jump to c --- diff --git a/Makefile b/Makefile index 2563e88..143f75d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CC=$(TOOLROOT)/arm-none-eabi-gcc +CC=arm-none-eabi-gcc LD=arm-none-eabi-ld AR=$(TOOLROOT)/arm-none-eabi-ar AS=arm-none-eabi-as @@ -12,7 +12,8 @@ as: all: $(AS) $(CFLAGS) -o start.o start.asm - $(LD) -T link.ld -o start.out start.o + $(CC) $(CFLAGS) -c -o main.o main.c + $(LD) -nostartfiles -T link.ld -o start.out start.o main.o $(MKIMG) -Obinary -R .data start.out kernel.bin run: diff --git a/link.ld b/link.ld index 903f1f5..5791784 100644 --- a/link.ld +++ b/link.ld @@ -4,7 +4,7 @@ MEMORY SRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K } -ENTRY(_start) +ENTRY(_start) SECTIONS { diff --git a/main.c b/main.c new file mode 100644 index 0000000..57a199e --- /dev/null +++ b/main.c @@ -0,0 +1,7 @@ +void main(void); + +void main(void ) { + + int i = 1; + for (;;); +} diff --git a/start.asm b/start.asm index 8af6fea..3c92e9b 100644 --- a/start.asm +++ b/start.asm @@ -9,23 +9,11 @@ _start: /* Start of main program */ start: - movs r0, #5 - movs r1, #1 -loop: - adds r1, r0 - subs r0, #1 - bne loop - /* Result is now in R1 */ - ldr r0, =Result - str r1, [r0] - -deadloop: - b deadloop + b main + b start .data - .word 0 /* add two words*/ - .word 0 Result: - .word 0 /* results now is in 0x20000008 (0x20000000 + 2 w) */ + .word 'X' /* results now is in 0x20000008 (0x20000000 + 2 w) */ .end