Hi,

thanks for sharing, my code seems to have the same pedigree,
although it is different.

I did not compile your code but it looks it suffers
from the same issue, ie there are pointers
(and generic pointers at that) the usage of
which seems to produce a lot of code.

My code compiles to about 3 k which seems like a lot.

Looking (quickly) through the code I see
that most of the pointer usage is accessing
RAM so they could be __data. The exception is
the descriptors which are in Flash. My thinking
is that instead passing pointers to the
descriptors (of which there are only a handful)
these could be handled more shortly via temp
variable of __code pointer and then copying
with

__data void *memcpypgm2ram(__data void *, __code void *, size_t);



I'm fishing for a tips and best
practices how to handle pointers. Maybe the
best practice is to avoid them....

br Kusti
 


> From: Vaclav Peroutka <[email protected]>
> Reply-To: <[email protected]>
> Date: Tue, 9 Feb 2010 09:46:12 +0200
> To: <[email protected]>
> Conversation: [Sdcc-user] PIC (18F) code generation tips...
> Subject: Re: [Sdcc-user] PIC (18F) code generation tips...
> 
> Hi Kusti,
> 
> I changed Alexander Enzmann's stack to support CDC. I am still planning to put
> it somewhere on the web (maybe some SVN).
> 
> Anyway, here is the initial version which worked for me during tests.
> 
> Vaclav
> 
>> ------------ Původní zpráva ------------
>> Od: Kustaa Nyholm <kustaa.nyh...@.....>
>> Předmět: [Sdcc-user] PIC (18F) code generation tips...
>> Datum: 08.2.2010 21:07:50
>> ----------------------------------------
>> Hi,
>> 
>> I'm converting a USB CDC  sample that I found in the net to run on my
>> 18F4550.
>> 
>> At preset the code is too big to fit into my memory, so I need to squeeze it
>> a bit. On inspecting the source code and generated code I noticed
>> quite a bit of code gets emitter because of the use of generic pointers.
>> 
>> For example there is:
>> 
>> static unsigned char *out_ptr;           // Data to send to the host
>> static unsigned char *in_ptr;            // Data from the host
>> 
>> which gets used like:
>> 
>>       for (i=0;i<bufferSize;i++)
>>       {
>>               *in_ptr++ = *out_ptr++;
>>       }
>> 
>> 
>> and like:
>> 
>> code config_struct config_descriptor = {
>> 
>>     <snip>
>> 
>>       out_ptr = (unsigned char *)&config_descriptor;
>>       count = *(out_ptr + 2);
>> 
>> So the data pointed to is sometimes in ROM/code (the USB descriptors)
>> and some times in RAM.
>> 
>> Quite a lot of code and some library calls gets emitted for all this.
>> 
>> What would be my best strategy to rework this?
>> 
>> br Kusti
>> 


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to