summaryrefslogtreecommitdiff
path: root/fpcsrc/rtl/linux/m68k/prt0.as
blob: de2cea8d89d0ab9f81c6368c049da404a28cf657 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#
#   This file is part of the Free Pascal run time library.
#   Copyright (c) 1999-2004 by Michael Van Canneyt, Peter Vreman,
#   & Daniel Mantione, members of the Free Pascal development team.
#
#   See the file COPYING.FPC, included in this distribution,
#   for details about the copyright.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY;without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
#**********************************************************************}
#
# Linux ELF startup code for Free Pascal
#
# The code in this file is the default startup code, it is used unless
# libc is linked in, profiling is enabled or you are compiling a shared
# library.
#

/*
   %a1          Contains a function pointer to be registered with `atexit'.
                This is how the dynamic linker arranges to have DT_FINI
                functions called for shared libraries that have been loaded
                before this code runs.

   %sp          The stack contains the arguments and environment:
                0(%sp)                        argc
                4(%sp)                        argv[0]
                ...
                (4*argc)(%sp)                NULL
                (4*(argc+1))(%sp)        envp[0]
                ...
                                        NULL
*/

        .text
        .globl _start
        .type _start,@function
_start:
        /* Clear the frame pointer.  The ABI suggests this be done, to mark
           the outermost frame obviously.  */
        sub.l %fp, %fp

        /* Extract the arguments as encoded on the stack and set up the
           arguments for `main': argc, argv.  envp will be determined
           later in __libc_start_main.  */
        move.l 8(%sp), %d0
        move.l %d0, operatingsystem_parameter_envp
        move.l 4(%sp), %d0
        move.l %d0, operatingsystem_parameter_argv
        move.l (%sp), %d0
        move.l %d0, operatingsystem_parameter_argc

        jbsr PASCALMAIN

        illegal                        /* Crash if somehow `exit' does return.  */

.file "prt0.as"
	.text
   .globl __entry
__entry:
   jsr  PASCALMAIN


        .globl  _haltproc
        .type   _haltproc,@function
_haltproc:
        move.l #1,%d0
        move.l operatingsystem_result,%d1
        trap  #0
        bras  _haltproc

.bss
        .type operatingsystem_parameters,@object
        .size operatingsystem_parameters,12
operatingsystem_parameters:
        .skip 3*4

        .global operatingsystem_parameter_envp
        .global operatingsystem_parameter_argc
        .global operatingsystem_parameter_argv
        .set operatingsystem_parameter_envp,operatingsystem_parameters+0
        .set operatingsystem_parameter_argc,operatingsystem_parameters+4
        .set operatingsystem_parameter_argv,operatingsystem_parameters+8