#include <m/proc.h>
#include <stdint.h>

extern volatile uint8_t __bss_start[];
extern volatile uint8_t __bss_end[];

extern void app_main (void);

static void msl_clear_bss (void) {
  uint8_t* p = (uint8_t*)__bss_start;
  while (p < __bss_end) {
    *p++ = 0;
  }
}

void __premain (void) {
  msl_clear_bss ();

  app_main ();

  m_proc_quit ();
}
