Original Code Posted                    |  What he simulated
________________________________________|_______________________________________________
                                        |
                                        |  #define PACKETLEN  5
                                        |  void comhandle(void);
                                        |
char packet[10];                        |  unsigned char combuf[PACKETLEN]; //com buffer
unsigned char byte_no=0;                |  unsigned char bufcntr=0;
                                        |
bit bdata txbit=0, rxbit=0, end_comm=0; |
                                        |
void serial(void) interrupt 4           |  void serialhandler(void) interrupt 4
{                                       |  {
       if(TI)    txbit=1;               |     TI=0;
       if(RI)                           |     if(RI)
       {                                |     {
            rxbit=1;                    |
            comhandle();                |         comhandle();
                                        |         RI=0;
       }                                |     }
}                                       |  }
                                        |
void comhandle(void)                    |  void comhandle(void)
{                                       |  {
      packet[byte_no]=SBUF;             |     combuf[bufcntr]=SBUF;
      byte_no++;  //suspicion           |     bufcntr++;
                                        |
      if(byte_no==9)                    |     if(bufcntr>=PACKETLEN)
      {                                 |     
           byte_no=0;                   |        bufcntr=0;
           end_comm=1;                  |  
      }                                 |
}                                       | }