Hello all, 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 understand that if I don't use any interrupt, I can reduce "vectors" page to 0x04, can't I ? - When is it necessary to use "crt0i" instead of "crt0" ? Thank you in advance, Vasek /* main.c */ /*************** pin definitions *****************/ #define LED_TRIS TRISCbits.TRISC0 #define LED_PIN LATCbits.LATC0 #define SWUART_TX_TRIS TRISBbits.TRISB6 #define SWUART_TX_PIN LATBbits.LATB6 #include <pic18fregs.h> #pragma stack 0x300 150 __code char __at(__CONFIG1H) conf1h = 0x02; // Select HS OSC __code char __at(__CONFIG2L) conf2l = 0x1e; // BOREN enabled, PWRTEN enabled __code char __at(__CONFIG2H) conf2h = 0x00; // WDT disabled __code char __at(__CONFIG3H) conf3h = 0x00; // digi RB pins, TMR1 normal __code char __at(__CONFIG4L) conf4l = 0x81; // Disable LVP, disable ext. mode void swuart_put( unsigned char aChar) __wparam; void swuart_del( void); void WWdelay (void); /******************* main() ***********************/ void main() { OSCCON = 0x70; LED_TRIS = 0; SWUART_TX_TRIS = 0; do { swuart_put( 0x55); swuart_put( 0xaa); swuart_put('H'); swuart_put('e'); swuart_put('l'); swuart_put('l'); swuart_put('o'); swuart_put(0x0d); WWdelay(); LED_PIN = 0; WWdelay(); LED_PIN = 1; } while (1); } /***********************************************************/ /* software UART - 9600Bd @ 10MHz */ void swuart_del() { unsigned char icnt2; for( icnt2 = 0; icnt2 < 80; icnt2++) ; } void swuart_put( unsigned char aChar) __wparam { unsigned char cnt; //INTCONbits.GIE = 0; SWUART_TX_PIN = 0; swuart_del(); for (cnt = 0; cnt < 8; cnt++) { if (aChar & 0x01) { SWUART_TX_PIN = 1; } else { SWUART_TX_PIN = 0; } aChar >>= 1; swuart_del(); } SWUART_TX_PIN = 1; //INTCONbits.GIE = 1; swuart_del(); swuart_del(); } void WWdelay (void) { volatile unsigned char tmpc; for(tmpc = 0; tmpc < 250; tmpc++) swuart_del(); } ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user