From 0c7ff283cb17c203da9a98fbd82ed87aa75abe52 Mon Sep 17 00:00:00 2001 From: Robin Krens Date: Mon, 8 Jul 2019 21:39:02 +0800 Subject: [PATCH] jump to c --- Makefile | 5 +++-- link.ld | 2 +- main.c | 7 +++++++ start.asm | 18 +++--------------- 4 files changed, 14 insertions(+), 18 deletions(-) create mode 100644 main.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 -- 2.7.4