PDA

View Full Version : I'm running out of code space example.



retepsnikrep
- 21st June 2010, 19:14
In this link Melanie gives an example of how to save code space by forcing variables into bank0.

http://www.picbasic.co.uk/forum/content.php?r=91-I%E2%80%99m-Running-Out-of-CodeSpace-What-Can-I-Do

Some questions.

1) Why are only some of the variables in the example prefaced with bank0?

2) Why doesnt everyone just do this as a matter of course for all variables?

3) I tried doing this with my large 16F886 program and it's 50 or so variables which uses 5555 words as reported by MCS. It made no difference and MCS still reportrs 5555 words used?

rsocor01
- 21st June 2010, 19:31
I think that newer versions of PBP already handle this variables and memory bank issue. That is why you didn't see any difference.

Robert

Darrel Taylor
- 21st June 2010, 20:33
> 1) Why are only some of the variables in the example prefaced with bank0?
Placing the most frequently used variables in BANK0 will give the most benefit.

> 2) Why doesnt everyone just do this as a matter of course for all variables?
BANK 0 is only a portion of the available RAM.
They can't all fit in BANK0, and it takes some careful thought to figure out which ones should be there.

> 3) I tried doing this with my large 16F886 program and it's 50 or so variables which uses 5555 words as reported by MCS. It made no difference and MCS still reportrs 5555 words used?
On a 16F886, BANK0 has 96 bytes.
PBP will use ~24 of them for system variables.
If you have another 50 BYTE sized variables, they will all end up in BANK0 anyhow.
So specifying BANK0 won't make any difference.

If you have 200 variables some words and arrays, then placing the most frequently used variables in BANK0 can save quite a bit of space.

Grouping variables in other banks that are used within a single subroutine can also save some since there is less bank switching to do between those particular vars.

hth,