fix regnual/sys.c
authorNIIBE Yutaka <gniibe@fsij.org>
Mon, 28 May 2012 02:03:26 +0000 (11:03 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Mon, 28 May 2012 02:03:26 +0000 (11:03 +0900)
regnual/sys.c

index fc8d0a9..702e4c8 100644 (file)
@@ -15,28 +15,21 @@ void entry (void)
 {
   asm volatile ("ldr   r0, =__ram_end__\n\t"
                "ldr    r1, =__main_stack_size__\n\t"
-               "subs   r0, r0, r1\n\t"
-               "msr    PSP, r0\n\t" /* Process (main routine) stack */
-               "movs   r0, #0\n\t"
+               "sub    r0, r0, r1\n\t"
+               "mov    sp, r0\n\t"
+               "mov    r0, #0\n\t"
                "ldr    r1, =_bss_start\n\t"
-               "ldr    r2, =_bss_start\n"
+               "ldr    r2, =_bss_end\n"
        "0:\n\t"
-               "cmp    r1, r2\n\t"
-               "bge    1f\n\t"
-               "str    r0, [r1]\n\t"
-               "adds   r1, r1, #4\n\t"
-               "b      0b\n"
-       "1:\n\t"
-               "movs   r0, #2\n\t" /* Switch to PSP */
-               "msr    CONTROL, r0\n\t"
-               "isb\n\t"
-               "movs   r0, #0\n\t"
-               "msr    BASEPRI, r0\n\t" /* Enable interrupts */
-               "cpsie  i\n\t"
+               "str    r0, [r1], #4\n\t"
+               "cmp    r2, r1\n\t"
+               "bhi    0b\n\t"
+               "cpsie  i\n\t"  /* Enable interrupts */
+               "mov    r0, #0\n\t"
                "mov    r1, r0\n\t"
                "bl     main\n"
-       "2:\n\t"
-               "b      2b\n"
+       "1:\n\t"
+               "b      1b\n"
                : /* no output */ : /* no input */ : "memory");
 }