]> robinkrens.nl - git repository - cortex-from-scratch/commitdiff
jump to c
authorRobin Krens <robin@robinkrens.nl>
Mon, 8 Jul 2019 13:39:02 +0000 (21:39 +0800)
committerRobin Krens <robin@robinkrens.nl>
Mon, 8 Jul 2019 13:39:02 +0000 (21:39 +0800)
Makefile
link.ld
main.c [new file with mode: 0644]
start.asm

index 2563e880dcbcb0a811eb78892eadda9be0114573..143f75de5a0287b54cacb5a226f360d157e70954 100644 (file)
--- 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 903f1f51a4c166e1d3437fd546e8f63959319865..5791784d635216098604019e6459add23a819417 100644 (file)
--- 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 (file)
index 0000000..57a199e
--- /dev/null
+++ b/main.c
@@ -0,0 +1,7 @@
+void main(void);
+
+void main(void ) {
+
+       int i = 1;
+       for (;;);
+}
index 8af6feac6ef3e1640b829cd0e1750bf8b8dbacb9..3c92e9bbb42f04e2802363c14aa798cf3a9426e0 100644 (file)
--- 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