Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!gatech!amdcad!tim From: tim@amdcad.UUCP Newsgroups: comp.lang.c Subject: Re: static variables [really segments] Message-ID: <17000@amdcad.AMD.COM> Date: Thu, 4-Jun-87 14:05:46 EDT Article-I.D.: amdcad.17000 Posted: Thu Jun 4 14:05:46 1987 Date-Received: Sat, 6-Jun-87 08:31:00 EDT References: <7653@brl-adm.ARPA> <196@peaks.UUCP> Reply-To: tim@amdcad.UUCP (Tim Olson) Organization: Advanced Micro Devices, Inc., Sunnyvale, Ca. Lines: 52 Keywords: data1 In article <196@peaks.UUCP> bdw@peaks.UUCP (bruce welker) writes: > Where "some string" actually is is up to the compiler writer. The > two places I can think of off-hand are: > - in the code > - in some hidden global data area > Would some one who's written a C compiler comment on this? > > Bruce Welker > ...!hao!boulder!peaks!bdw This is what the "data 1" segment is for on PCC compilers. Normal initialized statics are stored in the "data" segment, while strings are placed in data 1 or data 2, depending upon the type of initialization. This allows the compiler to switch back-and-forth between segments to generate strings in the middle of generating another structure: ------------------------- char *strings[] = { "this", "is", "a test" }; ------------------------- LL0: .data .data ; use the default data segment .align 2 .globl _strings ; create a global label _strings: .data 2 ; switch to the "data 2" segment L12: ; generate a local (hidden) label .ascii "this\0" ; generate the string .data ; switch back to the default segment .long L12 ; generate a pointer to the string .data 2 L13: .ascii "is\0" .data .long L13 .data 2 L14: .ascii "a test\0" .data .long L14 .data -- Tim Olson Advanced Micro Devices ..ihnp4!amdcad!tim