From: Robin Krens Date: Fri, 5 Jul 2019 09:49:05 +0000 (+0800) Subject: static RAM (.data) usage X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=2dcce7050a791e5b3ff81e9c785d05aa79f57ba0;p=cortex-from-scratch static RAM (.data) usage --- diff --git a/Makefile b/Makefile index cc01e47..2563e88 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ as: all: $(AS) $(CFLAGS) -o start.o start.asm $(LD) -T link.ld -o start.out start.o - $(MKIMG) -Obinary start.out kernel.bin + $(MKIMG) -Obinary -R .data start.out kernel.bin run: qemu-system-arm -monitor stdio -M lm3s6965evb -kernel kernel.bin diff --git a/link.ld b/link.ld index 00ce90e..903f1f5 100644 --- a/link.ld +++ b/link.ld @@ -1,6 +1,6 @@ MEMORY { - FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K + FLASH (xr) : ORIGIN = 0x00000000, LENGTH = 512K SRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K } diff --git a/start.asm b/start.asm index 8991594..8af6fea 100644 --- a/start.asm +++ b/start.asm @@ -9,14 +9,23 @@ _start: /* Start of main program */ start: - movs r0, #10 - movs r1, #5 + movs r0, #5 + movs r1, #1 loop: adds r1, r0 subs r0, #1 bne loop -/* Result is now in R1 */ + /* Result is now in R1 */ + ldr r0, =Result + str r1, [r0] + deadloop: b deadloop + + .data + .word 0 /* add two words*/ + .word 0 +Result: + .word 0 /* results now is in 0x20000008 (0x20000000 + 2 w) */ .end