Searching \ for 'C compilers and paging' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/language/index.htm?key=c
Search entire site for: 'C compilers and paging'.

Truncated match.
PICList Thread
'C compilers and paging'
1999\01\19@165647 by John Payson

flavicon
face
In one of the projects I've been doing with a 16C74 and the CCS
compiler, I've been having some difficulties with the arrangement
of code and data in memory.  In particular, I've found that making
small changes to the code can result in significant changes in code
size as routines and variables move around.

As an example, I have a putch() equivalent routine which is called
from 5 places in page 0 and 42 places in page 1.  If the compiler
happens to place the routine in page 0, then 84 bsf/bcf instructions
will be needed to set/clear PCLATH.3; if the routine is placed into
page 1, then only 10 such instructions will be needed.

Does anyone know of any good way to convince the compiler that certain
routines belong in certain pages?  Is such a thing easily possible
with the HiTech C compiler?  What about data paging?  Can the HiTech
compiler easily be informed of things like:

- This variable is used frequently, and should be in page 0.

- This variable is accessed seldom; putting it in page 1 should be no
  problem.

- This variable should be globally-accessible.  Put it in the $70-$7F
  block (on chips that have one) and don't use RP0 when accessing it.

I generally like the CCS compiler (and have gotten used to it) but it's
frustrating that there's no way to convince it to put things in the best
spot.

1999\01\21@010652 by Gerhard Fiedler

picon face
At 15:54 01/19/99 -0600, John Payson wrote:
>As an example, I have a putch() equivalent routine which is called
>from 5 places in page 0 and 42 places in page 1.  If the compiler
>happens to place the routine in page 0, then 84 bsf/bcf instructions
>will be needed to set/clear PCLATH.3; if the routine is placed into
>page 1, then only 10 such instructions will be needed.
>
>Does anyone know of any good way to convince the compiler that certain
>routines belong in certain pages?  Is such a thing easily possible
>with the HiTech C compiler?  What about data paging?  Can the HiTech
>compiler easily be informed of things like:
>
> - This variable is used frequently, and should be in page 0.
>
> - This variable is accessed seldom; putting it in page 1 should be no
>   problem.
>
> - This variable should be globally-accessible.  Put it in the $70-$7F
>   block (on chips that have one) and don't use RP0 when accessing it.

no answer yet? i'll try:

the hitech compiler has a (pretty feature-complete) linker, and therefore
the whole thing looks quite a bit different than with the ccs compiler. i
don't know about all the features and options, but each source file (code
and static data) can be positioned individually by linker options and
static data can be declared to be in banks 1 to 3 in the source code. i'm
not sure about putting static data in bank 0, AFAIK it is reserved for auto
variables, but it's probably possible to do it with the linker (eg. by
collecting all those, then global, variables in one file and linking it
with the appropriate option). i don't know whether the compiler can use the
0x70 block in the way you mentioned.

ge

1999\01\21@013802 by Tjaart van der Walt

flavicon
face
Gerhard Fiedler wrote:
{Quote hidden}

A scary exercise is to load your list file into your favourite
word processor. Search & replace all "BSF RP" to "BANK" Do the
same with "BCF RP". Now do a word count on "BANK". Make sure
you sit down first :(

FYI, (I think) the MPC compiler has an algorithm that
allocates memory in a way that would minimise bank switching.
Damn clever, if you ask me...

Now if only we can get a MPLAB that actually uses the .COD
file correctly (and all the information in it), I'd be
sooooooo happy.

--
Friendly Regards          /"\
                         \ /
Tjaart van der Walt        X  ASCII RIBBON CAMPAIGN
spam_OUTtjaartTakeThisOuTspamwasp.co.za  / \ AGAINST HTML MAIL
|--------------------------------------------------|
|                WASP International                |
|R&D Engineer : GSM peripheral services development|
|--------------------------------------------------|
| Mobile : .....tjaartKILLspamspam@spam@sms.wasp.co.za  (160 text chars) |
|     http://www.wasp.co.za/~tjaart/index.html     |
|Voice: +27-(0)11-622-8686  Fax: +27-(0)11-622-8973|
|          WGS-84 : 26¡10.52'S 28¡06.19'E          |
|--------------------------------------------------|

1999\01\21@080738 by Andy Kunz

flavicon
face
>static data can be declared to be in banks 1 to 3 in the source code. i'm
>not sure about putting static data in bank 0, AFAIK it is reserved for auto
>variables, but it's probably possible to do it with the linker (eg. by
>collecting all those, then global, variables in one file and linking it
>with the appropriate option). i don't know whether the compiler can use the
>0x70 block in the way you mentioned.

Data goes into Bank0 unless specified by the source code to go elsewhere.

Auto variables MUST be in bank0, though.

Andy


  \-----------------/
   \     /---\     /
    \    |   |    /          Andy Kunz
     \   /---\   /           Montana Design
/---------+   +---------\     http://www.montanadesign.com
| /  |----|___|----|  \ |
\/___|      *      |___\/     Go fast, turn right,
                              and keep the wet side down!

1999\01\21@115123 by Peter Schultz

flavicon
face
Hi,
I did that " very scary exercise" and I was not find any scary thing. Can You explain me what I suppose to find?
I think this issue is depend on how smartly structurized your program and my opinion the compiler not suppose to fix mistake made by by the programmer. The easiest thing is saying: Oh, my program is so bad becasue this idiot compiler.  Also I believe you can make so badly structurized program in assembler.
Cheers,
Peter Schultz
<schupetspamKILLspamdvp.com>
DVP Inc.
3430 Ocean View Blvd. Unit A
Glendale, CA 91208
(818) 541-9020
Fax: (818) 541-9423

{Original Message removed}

1999\01\22@000000 by Tjaart van der Walt

flavicon
face
Peter Schultz wrote:
>
> Hi,
> I did that " very scary exercise" and I was not find any scary thing. Can You explain me what I suppose to find?

You were supposed to find that these functionless
instructions take up between 15% and 25% of your
code space. So you are paying less for a 8 bit
micro, only to pay more for the code space. Put
differently, your 4k PIC, is actually a 3k PIC.
Now isn't that scary?

> I think this issue is depend on how smartly structurized your program and my opinion the compiler not suppose to fix mistake made by by the programmer. The easiest thing is saying: Oh, my program is so bad becasue this idiot compiler.  Also I believe you can make so badly structurized program in assembler.

I am not blaming any compiler. I am just saying
all compilers are not equal. I have 4 legal copies
of different compilers, and can assure you they
are not the same.

If your compiler is smart enough to minimise
these stupid bank switching statements by using
the memory wisely, you are better off.

BTW the Scenix SX has simple (read : single)
intructions to switch between banks. This cuts
the switching code in half.

--
Friendly Regards          /"\
                         \ /
Tjaart van der Walt        X  ASCII RIBBON CAMPAIGN
.....tjaartKILLspamspam.....wasp.co.za  / \ AGAINST HTML MAIL
|--------------------------------------------------|
|                WASP International                |
|R&D Engineer : GSM peripheral services development|
|--------------------------------------------------|
| Mobile : EraseMEtjaartspam_OUTspamTakeThisOuTsms.wasp.co.za  (160 text chars) |
|     http://www.wasp.co.za/~tjaart/index.html     |
|Voice: +27-(0)11-622-8686  Fax: +27-(0)11-622-8973|
|          WGS-84 : 26¡10.52'S 28¡06.19'E          |
|--------------------------------------------------|

1999\01\22@013213 by Gerhard Fiedler

picon face
At 07:07 01/22/99 +0200, Tjaart van der Walt wrote:
>I am not blaming any compiler. I am just saying
>all compilers are not equal. I have 4 legal copies
>of different compilers, and can assure you they
>are not the same.

would you mind a brief explanation (maybe with some enlightening code
statistics) of how this matter is handled differently by the different
compilers (maybe even by name :-)?

ge

1999\01\22@015938 by Tjaart van der Walt

flavicon
face
Gerhard Fiedler wrote:
>
> At 07:07 01/22/99 +0200, Tjaart van der Walt wrote:
> >I am not blaming any compiler. I am just saying
> >all compilers are not equal. I have 4 legal copies
> >of different compilers, and can assure you they
> >are not the same.
>
> would you mind a brief explanation (maybe with some enlightening code
> statistics) of how this matter is handled differently by the different
> compilers (maybe even by name :-)?
>
> ge

To name them : NITPIC, MPLABC, CCS, and MPC

I am totally biased in favour of MPC, but there is a
comparison between different C compilers on one of
the PIClisters web page (I can't remember who's).

Can anyone else remember?

--
Friendly Regards          /"\
                         \ /
Tjaart van der Walt        X  ASCII RIBBON CAMPAIGN
tjaartspamspam_OUTwasp.co.za  / \ AGAINST HTML MAIL
|--------------------------------------------------|
|                WASP International                |
|R&D Engineer : GSM peripheral services development|
|--------------------------------------------------|
| Mobile : @spam@tjaartKILLspamspamsms.wasp.co.za  (160 text chars) |
|     http://www.wasp.co.za/~tjaart/index.html     |
|Voice: +27-(0)11-622-8686  Fax: +27-(0)11-622-8973|
|          WGS-84 : 26¡10.52'S 28¡06.19'E          |
|--------------------------------------------------|

1999\01\22@094025 by Andy Kunz

flavicon
face
>> would you mind a brief explanation (maybe with some enlightening code
>> statistics) of how this matter is handled differently by the different
>> compilers (maybe even by name :-)?
>>
>> ge
>
>To name them : NITPIC, MPLABC, CCS, and MPC
>
>I am totally biased in favour of MPC, but there is a
>comparison between different C compilers on one of
>the PIClisters web page (I can't remember who's).
>
>Can anyone else remember?

Well, CCS had one for a while but it was totally outdated.

The paging problem is a recognized thing, and HiTech has done some pretty
creative stuff on it.  I found a 12+% decrease in code space after the
latest version, solely due to a smarter linker which reduces the banking
stuff for calls.

Andy


  \-----------------/
   \     /---\     /
    \    |   |    /          Andy Kunz
     \   /---\   /           Montana Design
/---------+   +---------\     http://www.montanadesign.com
| /  |----|___|----|  \ |
\/___|      *      |___\/     Go fast, turn right,
                              and keep the wet side down!

1999\01\22@115400 by John Payson

flavicon
face
|A scary exercise is to load your list file into your favourite
|word processor. Search & replace all "BSF RP" to "BANK" Do the
|same with "BCF RP". Now do a word count on "BANK". Make sure
|you sit down first :(

I wrote a little program that would read in a .hex file and
output, for each page (and aggregate for the whole program)...

- The number of unused words
- The number of writes to RP0
- The number of writes to PCLATH[3-4]
- The number of retlw's (used to see where strings are going)

Once I know what's good/bad that can give a good clue as to what
to look for.

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...