Path: chuka.playstation.co.uk!news From: Jim Newsgroups: scee.yaroze.programming.gnu_compiler Subject: Re: Memory allocation probs... Date: Wed, 29 Oct 1997 11:43:43 +0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 56 Message-ID: <3457216F.61478ECA@micronetics.com> References: <34551BB5.58BA@dial.pipex.com> <3454c596.21265918@news.playstation.co.uk> <3456076E.92B9FC58@micronetics.com> <3456FA5F.DB8@dial.pipex.com> <345695E0.6102@peace.co.nz> NNTP-Posting-Host: jim.micronetics.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.01 [en] (Win95; I) X-Priority: 3 (Normal) Here's how I understand everything. The stack starts at the last 4 bytes of memory (0x801ffffd) and works it way down. I load all data starting at 0x80090000 and link my code to run at 0x80100000. The psx kernel ends at 0x80090000. You have to be cautious when loading data after your code and programs data segments (anything > 0x80100000) because the BSS segment is located past the end of the program but is not actually located within the program binary when you upload it. Use the 'size' command on your program to see how large it really is. It's quite possible for your program to knob over your data file at runtime if they are located too close to the end of your code or static data. It also means that you could start getting spurious errors as your data files get trolleyed. Malloc etc grabs memory from the heap. This is located wherever you tell it with the InitHeap command. This is different under codewarrior, look at the startup stub for codewarrior to see how they do this. I now compress all my data files to speed upload times, but I still think I have to exceed the 0x80100000 limit for data. -Jim James Russell wrote: > > Chris Chadwick wrote: > > > > Thanks to all who replied to my post! > > > > James Russell: > > Im linking to 80100000 because I load all my data/TIMs into low > > mem, before the prog. Where in mem do you load your data files? > > > > I link program to 0x80090000 (methinks) and data to 0x80100000. > That's just a rip off of some example code though - the only reasoning > I'd put behind it is that 0x80090000 is just above the PSX Library, and > 0x80100000 is slap bang in the middle of writable mem, so though the > size of my code is variable, it shouldn't ever be overwritten by by > data. > > Judging by the file size, code size is really small for most programs > (sub 64K). I'm assuming that alloc() grabs memory from the top of mem, > just below the stack, and works it's way down. Is this correct Sony? > > J > > -- > ==PEACE COMPUTERS > ==James.Russell@peace.co.nz - 64(9)3730400 -Fax 64(9)3730401 > > LAPD Motto: Let's leave early and beat the crowd.