Path: chuka.playstation.co.uk!news From: Chris Chadwick Newsgroups: scee.yaroze.programming.gnu_compiler Subject: Re: Optimise Problem - trunced data Date: Wed, 06 Aug 1997 01:36:15 -0700 Organization: PlayStation Net Yaroze (SCEE) Lines: 64 Message-ID: <33E8377F.366F@dial.pipex.com> References: <333d7fd9.23907964@news.playstation.co.uk> <33424023.72C4@interactive.sony.com> <33D5B732.3AC9@dial.pipex.com> <01bc9c44$3fe961e0$ca2c9ac2@martin.snsys.com> <33E39782.6C3F@dial.pipex.com> <01bca0db$fb8dfdc0$ca2c9ac2@martin.snsys.com> NNTP-Posting-Host: ad123.du.pipex.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.02 (Win95; I; 16bit) Martin Day wrote: > > Chris Chadwick wrote in article > <33E39782.6C3F@dial.pipex.com>... > > ... > > > > Hmmmm! Neat solution, Martin ;) > > > > Of course we still couldnt optimize the code module that actually > > assigns the address of PSDCNT etc. to the pointers as the mere > > mention of these variables, using optimization, turns the compiler > > egg-shaped. > > If you simply initialise global variables with the address as in my example > : > > int *pmath_errno = &math_errno; > > then it should work fine. Doesn't this work for you? Yes, sorry, this does work! :) I was just *assuming* that any mention of these globals would cause problems without first trying out what you had suggested... > Here's another alternative that I think should work though I've not been > able to try it properly. Modify the declarations in libps.h to change > > extern u_long PSDCNT; > > to > > extern u_long PSDCNT[]; > > and now use *PSDCNT to access this variable (or PSDCNT[0] if you prefer). > Since you don't tell the compiler the dimension of the 'array' PSDCNT it > decides it must be in the .data section rather than .sdata and so won't > optimise the accesses to it. I've tried this method too and it seems to work fine ;) You are obviously more clued about the workings of the compiler than me (not difficult :) so I was wondering if you could explain what the 4 program sections - that are listed when dowloading a prog - actually contain: .text, .sdata, .rdata and .data ... I assume .text is the actual executable program code and, from your above desciption, .sdata (s for session?) holds global data ? > Change the variables that are arrays, e.g. > > extern short PSDOFSX[2], PSDOFSY[2]; > > to unspecified dimension too, i.e. > > extern short PSDOFSX[], PSDOFSY[]; > > in this example. > > -- > Martin martin@snsys.com +44 117 929 9733 Thanks for your help, Martin - that's another problem nailed! :) Chris