; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; -*- Mode: Assembler -*-
;* Lastedit: 22 Feb 90 16:06:44 by Harry Meekings *
; driver code to call _main for NorCroft C system.
; Version to sit on top of shared library kernel
;
; Copyright (C) Acorn Computers Ltd., 1988.
;

        GBLL    Brazil_Compatible
        GBLS    Calling_Standard
        GBLL    ModeMayBeNonUser
        GBLL    SharedLibrary

Brazil_Compatible  SETL  {FALSE}
Calling_Standard   SETS  "APCS_U"
ModeMayBeNonUser   SETL  {TRUE}
SharedLibrary      SETL  {TRUE}

        GET     s.h_Regs
        GET     s.h_Brazil
        GET     s.h_modmacro

        Module CLib

        AREA    |C$$data|

StaticData
dataStart
        GET     clib.s.cl_data

        AREA    |Lib$$Init|, READONLY

        IMPORT  |CLib_data_end|
        &       2
        &       entriesStart
        &       entriesEnd
        &       dataStart
        &       |CLib_data_end|


        AREA    |RTSK$$Data|, READONLY
        IMPORT  |C$$code$$Base|
        IMPORT  |C$$code$$Limit|

        &       EndRTSK-.
        &       |C$$code$$Base|
        &       |C$$code$$Limit|
        &       CLanguageString
        &       0               ; No initialisation
        &       Finalise        ; finalisation
        &       TrapHandler
        &       UncaughtTrapHandler
        &       EventHandler
        &       UnhandledEventHandler
        ; Note: with the shared C library, the stub contains no finalisation
        ; but the library does.  (and the kernel does library as well as
        ; client finalisation).  It needs to be this way rather than the
        ; obvious stub containing finalisation because early versions of the
        ; C library had none.
EndRTSK

        AREA    |C$$code|, CODE, READONLY

entriesStart
        GET     clib.s.cl_entries
entriesEnd

        EXPORT  |__main|
        ; The compiler produces references to this, so it must be defined,
        ; but it had better not be branched to.
|__main| & &E6000010
CLanguageString = "C",0
        ALIGN

        LNK     clib.s.cl_body