Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!elroy!cit-vax!oberon!skat.usc.edu!blarson From: blarson@skat.usc.edu.UUCP Newsgroups: comp.lang.c Subject: Re: Initialization of Externals (was Re: documentation standards...) Message-ID: <4903@oberon.USC.EDU> Date: Thu, 29-Oct-87 13:16:41 EST Article-I.D.: oberon.4903 Posted: Thu Oct 29 13:16:41 1987 Date-Received: Sat, 31-Oct-87 19:39:22 EST References: <9897@brl-adm.ARPA> <6917@prls.UUCP> <123@teletron.UUCP> Sender: nobody@oberon.USC.EDU Reply-To: blarson@skat.usc.edu (Bob Larson) Organization: USC AIS, Los Angeles Lines: 32 In article <123@teletron.UUCP> andrew@teletron.UUCP (Andrew Scott) writes: >In article <6917@prls.UUCP>, gardner@prls.UUCP (Robert Gardner) writes: >> I prefer compile-time initialization when possible, but it's not >> necessarily "for free". >This is true when dealing with ROM-able code. You are forced to write >explicit 'initialize()' procedures. I disagree. >Our compiler (like most others) generates different segments for different >portions of code: > .text - program instructions > .data - initialized externals > .bss - uninitialized externals >We bind the .text and .data sections to ROM addresses and .bss sections to >RAM addresses at link time. Thus, we are forced to allow initialized externals >for static data structures only. Variable data must be initialized by an >'initialize()' routine called from the startup code. On any compiler used to produce ROMable code, the copy should be part of the startup code. If your compiler wasn't designed for ROMable code, you can probably refit it by re-writing the startup routine. (the .data section must be allocated in both ROM and RAM.) The C program does not have to be changed at all. Examples of compilers that (always!) produce ROMable, reentrant, position-idependant code include all those sold by Microware for Os9/68k and Os9. -- Bob Larson Arpa: Blarson@Ecla.Usc.Edu Uucp: {sdcrdcf,cit-vax}!oberon!skat!blarson blarson@skat.usc.edu Prime mailing list (requests): info-prime-request%fns1@ecla.usc.edu