Welcome to mirror list, hosted at ThFree Co, Russian Federation.

crt0.c « z8ksim « sys « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f9aad6d95a32364fb9888cdd24feaced7f6d0d9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
extern char _start_bss;
extern char _end_bss;
extern int main(int argc, char **argv, char **environ);
void __main();

static void
enter()
{
#if defined(__Z8002__)
  __main();
#endif
  exit(main(0,0,0));
}
start()
{
  char *p;
#if defined(__Z8002__)
  asm("ld	r15,#__stack_top");
  asm("ld	r10,r15");
#endif
#if defined(__Z8001__)
  asm("ldl	rr14,#__stack_top");
  asm("ldl	rr10,rr14");
#endif


  /* zero bss */
  p = &_start_bss;
  while (p < & _end_bss) 
  {
    *p++ = 0;
  }
  enter();
}

#if defined(__Z8002__)
void __do_global_ctors ()
{
  typedef void (*pfunc)();
  extern pfunc __ctors[];
  extern pfunc __ctors_end[];
  pfunc *p;
  for (p = __ctors_end; p > __ctors; )
    {
      (*--p)();
    }
}

void __main()
{
  static int initialized;
  if (! initialized)
    {
      initialized = 1;
      __do_global_ctors ();
    }
}
#endif