Hi,

> I am working on PCB tester with programming capabilities for PIC - of  
> course in SDCC. I compile target.c, generated HEX is then processed into  
> .H file and linked together with code of the main application. Target  
> code is really simple, but it seems to me that overhead is quite big. I  
> tried the simplest code with LED blinking and SW UART (see below).
>
> If I compile it, the main code itself has about 216bytes (taken from  
> .LST). But when I link it, I get around 460 bytes. With  
> "--use-crt=crt0.o" I get  around 270 bytes, it is better.
>
> My questions are:
> - Why "vectors" page is 0x00-0x29 ? Where is said, how much memory I  
> need for INT jumps ? I feel that 2 bytes are enough - just "goto  
> __INT_HANDLER".

I do not know where this comes from, but it might be a joke: 0x2A equals
the famous 42 ... And no, 2 byte for the goto do not suffice: goto is
4 byte long. But 4 byte for the RESET vector should do fine iff you
do not use any interrupts. Do you really need the space for these < 20
instructions?!?

> - I understand that if I don't use any interrupt, I can reduce "vectors"  
> page to 0x04, can't I ?

You probably can, no guarantees, though: I never did that myself.

> - When is it necessary to use "crt0i" instead of "crt0" ?

crt0i initializes your global and/or static variables. Whenever you have

int flag = 1; /* initialized global variable */
int flag2 = 0; /* initialized global variable */

int foo(void)
{
   static int bar = 42; /* static variable */
   int baz = 4; /* <-- not static, would not require crt0i.o */
}

you need crt0i.o. Beware: Even initializing to 0 requires
either crt0i.o (or crt0iz.o, which clears all uninitialized
memory) to guarantee correct initialization after reboot
(and even after initial boot iff your memory was not 0
before).

In short: if you rely on a paritcular memory cell having a
defined value after startup, you need crt0i.

> void swuart_del()
> {
>    unsigned char icnt2;
>    for( icnt2 = 0; icnt2 < 80; icnt2++) ;
> }

Consider using __asm __endasm; as the loop body,
otherwise the compiler optimize your precious delay
loop away.

Best regards,
Raphael

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to