further ivt and isr implementation
[cortex-from-scratch] / start.asm
index 8af6fea..e4ca237 100644 (file)
--- a/start.asm
+++ b/start.asm
@@ -1,31 +1,40 @@
-       .equ STACK_TOP, 0x20000800
+       .equ STACK_TOP, 0x20008000 /* placed at 32kB, TODO: could place at top of SRAM? */
        .text
        .global _start
+       .global reset, nmi, hardfault
        .code 16
        .syntax unified
 _start:
-       .word STACK_TOP, start
-       .type start, function
+       .word STACK_TOP, reset, nmi, hardfault
+       .type reset, function
 
-/* 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] 
+/* A reset vector (or bootcode) will call main in main.c
+   this is the so called 'entry to C' */
+reset:
+       b main
+       b reset 
 
-deadloop:
-       b deadloop
+/* These are consequently the nmi and hardfault vector handlers
+   before booting and entering main, these can actually be called
+   (machine somehow has a failure). That's why they are included here.
+   Later the interrupt vector
+   will be relocated to SRAM and the will be copied / modified.  */
+
+nmi:
+       b nmi
+
+hardfault: 
+       b hardfault
+.global stub
+stub:
+       mov r1, #'z'
+       ldr r0, [r1]
+       bx lr
+       /* ldr R0,=10
+       mov R1,#0
+       udiv.w R2, R0, R1 */
 
        .data
-       .word 0 /* add two words*/
-       .word 0 
-Result:
-       .word 0 /* results now is in 0x20000008 (0x20000000 + 2 w) */
+       .word 'x' 
        .end