"Warning: statically allocated variables consume all ..

Discussion of issues related specifically to writing code for native mode devices. This includes ZBasic code as well as assembly language code and C code, both inline and standalone.
Post Reply
pjc30943
Posts: 220
Joined: 01 December 2005, 18:45 PM

"Warning: statically allocated variables consume all ..

Post by pjc30943 »

I think I've misunderstood the basics of how much system RAM is available.

As an example, accompanying the warning

Code: Select all

"Warning: statically allocated variables consume all available RAM, see 'Option HeapSize' and 'Option RamSize'"
is

Code: Select all

"No errors.  Target device: ZX1280n, Code: 30196 bytes, RAM: 9028 bytes, Persistent memory: 32 bytes"
How does 9k exceed 64k of external RAM if I use "Option ExtRamConfig On"? It seems perhaps there is a separate RAM required for stack use, etc. that must be internal to the device.
Paul
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: "Warning: statically allocated variables consume al

Post by dkinzer »

pjc30943 wrote:How does 9k exceed 64k of external RAM if I use "Option ExtRamConfig On"?
Lacking any advice to the contrary, the compiler assumes that a ZX-1280 has 8K of RAM available. The presence of Option ExtRamConfig On is not sufficient information since you might have 2K of external RAM or the full complement. The compiler has no way of knowing how much external RAM you might have.

The way to resolve this problem is to tell the compiler how much RAM you have using Option RamSize. A full complement of external RAM is expressed using the idiom shown below. Register.RamStart gives the starting address of internal RAM; subtracting that value from 64K yields the number of bytes of RAM available with an external RAM chip of 64K or more attached.

Code: Select all

Option RamSize 65536 - Register.RamStart
- Don Kinzer
pjc30943
Posts: 220
Joined: 01 December 2005, 18:45 PM

Post by pjc30943 »

Ah. That makes sense.

Based on
I thought that what you suggested wouldn't work because of the example Mike posted in the post asking about large arrays:
"In trying out code to respond to this question, I have found two potential problems for Don to resolve:
The following does not compile. The native mode Ramstart appears to be the same value as the ZVM when it fact it should be smaller.Code:

Code: Select all

Option RamSize 65536 - Register.RamStart
"
But looking further down that thread I see that this was resolved and is no longer an issue...
Paul
Post Reply