Boot1 tries to clear boot2's BSS. It makes several assumptions that are
[dragonfly.git] / sys / boot / i386 / btx / lib / btxcsu.S
1 /*
2  * Copyright (c) 1998 Robert Nordier
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are freely
6  * permitted provided that the above copyright notice and this
7  * paragraph and the following disclaimer are duplicated in all
8  * such forms.
9  *
10  * This software is provided "AS IS" and without any express or
11  * implied warranties, including, without limitation, the implied
12  * warranties of merchantability and fitness for a particular
13  * purpose.
14  *
15  * $FreeBSD: src/sys/boot/i386/btx/lib/btxcsu.s,v 1.3 1999/08/28 00:40:07 peter Exp $
16  * $DragonFly: src/sys/boot/i386/btx/lib/Attic/btxcsu.S,v 1.6 2004/07/27 19:37:19 dillon Exp $
17  */
18
19 /*
20  * BTX C startup code (ELF).  Executed from ../btx/btx.S
21  */
22
23 #include "../../bootasm.h"
24
25                 /*
26                  * Globals.
27                  */
28                 .global _start
29                 .extern _edata, _end
30
31                 /*
32                  * Client entry point.
33                  */
34 _start: 
35                 pushl %eax                      # Save base address
36                 movl $_edata,%edi               # Clear BSS
37                 movl $_end,%ecx
38                 subl %edi,%ecx
39                 subl %eax,%eax
40                 rep
41                 stosb
42                 popl __base                     # Set base address
43                 movl %esp,%eax                  # Get base of arguments
44                 addl $USR_ARGSPACE-USR_ARGOFFSET,%eax
45                 movl %eax,__args
46                 call main                       # Invoke client main()
47                 call exit                       # Invoke client exit()
48
49                 /*
50                  * Data
51                  */
52                 .comm __base,4                  # Client base address
53                 .comm __args,4                  # Client arguments