>
> Have a look at my CDC USB Stack which is based on the Nuts&Volts article
> about USB HID stack using sdcc.
Hi Jan,
thank you for sharing too, I had a look at the code
and it too seems to have the same pedigree and breeding
as my code and other previously mentioned USB pieces.
And it seems to suffer from the same issus, ie
it uses generic pointers that in PIC/sdcc use
three bytes of memory, not a big deal, and
the use of which generates a lot of code,
which is an issue right now for me.
Granted I did not compile your code yet but it
seems to have the same issue and I think it will
not fit into my remaining Flash without some
refactoring.
Below is small test I wrote to investigate
this issue, and as we can see every time
a generic pointer is used the compiler
will emit 1 - 5 words *more* code than
when using __data or __code pointers,
plus it will require pulling in a
library function or two to do the access.
To me it seems the best strategy
is to avoid pointers (although
in many times this results in uglier
code) and not to mix different types
of pointers. I think in USB case
it could make sense (not tried this yet)
to maintain a separate 'out' pointer
for stuff that comes from 'code' (ie
the descriptors etc) and 'data' (ie
the actual payload that we are
transfering).
The <string.h> library seems to offer
some funcions to do the copying
more efficiently than standard memcpy
or hand written loops:
__data void *memcpypgm2ram(__data void *, __code void *, size_t);
__data void *memcpyram2ram(__data void *, __data void *, size_t);
I'll see if I can reduce to code size
enough to fit my device.
br Kusti
#include <string.h>
volatile __data char* pd0;
volatile __data char* pd1;
volatile __code char* pc0;
volatile char* pg0;
data char da[100];
extern char ea0[];
extern char ea1[];
code char ca[]={0,1,2,3,4};
void test() {
pd0=da; // 5 words : data ptr
pc0=ca; // 7 words: code ptr
pg0=da; // 7 words: generic ptr to data
pg0=ca; // 6 words : generic pointer to code
pd0 = ea0;
pd1 = ea1;
pg0 = ea0;
*pd0 = *pd1; // 20 words, data to data
*pd0 = *pc0; // 19 words, code to data
*pd0 = *pg0; // 24 words (inc lib call), code to data
*pd0=12; // 10 words
*pg0=34; // 15 words
da[3] = 37; // 3 words
da[0]=0;
}
------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user