Dear SDCC developers:

I have the following  troubles using the SDCC compiler.

I'm using the uVison/51 limited version from Keil to compile my applications. These applications are working fine but can't get large code . When I compile the same code using the SDCC compiler the code work sometimes and othertimes it dont. Whenever I add any extra code I face this problem.

 I did a small program, this program is turning on /off a led connected to any pin of P1. When I compile it with Keil it works fine. When I compile it with SDCC it works OK but when I add any extra code it don't. I don’t know how to trace or how to make this code work always.

Any suggestions for the compilation process and make file. Please advice. The code is like the following:

#include <reg51.h>

#define FOSC 12000000 /* oscillator frequency (KHz) */

#define DELAY_1MS     (65535-FOSC/12000)        /* 1 millisecond delay */
#define DELAY_1MS_HI  (char)((DELAY_1MS >> 8) & 0x00ff)
#define DELAY_1MS_LO  (char)(DELAY_1MS & 0x00ff)

#define DELAY_50MS      (65535*50-FOSC/12000*50)  /* 50 millisecond delay */
#define DELAY_50MS_HI   (char)((DELAY_50MS >> 8) & 0x00ff)
#define DELAY_50MS_LO   (char)(DELAY_50MS & 0x00ff)

/* --------------------------------------------------------------------------
 *
 * FUNCTION NAME: Util_Delay
 * DESCRIPTION:   Delays program execution for 'hundred_ms' milliseconds
 * RETURN:        None.
 * NOTES:         Max delay is 255*50 milliseconds = 12.75 sec
 * ------------------------------------------------------------------------ */
void Util_Delay(unsigned char hundred_ms)
{
 int data i=hundred_ms << 1;  /* multiply by 2 for 50ms */
 TMOD = 0x01;    /* timer 0 in delay mode */
 TR0 = 0;     /* timer 0 stopped */
 while (i--)
 {
  TF0 = 0;    /* clear timer flag */
  TH0 = DELAY_50MS_HI; /* timer HIGH value */
  TL0 = DELAY_50MS_LO; /* timer LOW value */
  TR0 = 1;    /* timer 0 started */
  while (TF0==0);   /* wait for timer overflow */
  TR0 = 0;    /* timer 0 stopped */
 }
}

/*
** ===========================================================================
** main application routine
** ===========================================================================
*/
void main (void) {
 while (1) { /* loop forever */
      P1 = 0x55;
      Util_Delay(5);
      P1 = 0xAA;
      Util_Delay(5);
     }
}

/* ===========================================================================*/

With many thanks in advance.

-- Iyad