/*****************************************************************************
  Copyright (c) 2010 Rowley Associates Limited.
 
  This file may be distributed under the terms of the License Agreement
  provided with this software.
 
  THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE
  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *****************************************************************************/

  .text
  .code 32
  .align 0

  .global _start
  .global stack_start
  .global stack_end
  .extern _configure

/*****************************************************************************
  Function    : _start
  Description : Minimal startup code for C system.  
 *****************************************************************************/
_start:
  bl _configure

  /* Setup stack */
  ldr sp, =__stack_end__

  /* Zero the bss. */
  ldr r2, =__bss_start__
  ldr r3, =__bss_end__
  mov r4, #0
zero_bss_loop:
  cmp r2, r3
  beq zero_bss_end
  strb r4, [r2], #+1
  b zero_bss_loop
zero_bss_end:    

  /* Jump to main entry point */
  bl main

  /* Return from main, loop forever. */
loop:
  b loop
                  
