output confusion

I use an RF 315/434 MHz ASK RECEIVER and 315/434 MHz ASK TRANSMITTER for the communication between two 89c52 microcontrollers. I am a beginner. In the transmitter microcontroller i use the normal code for transmission of 1,2,3... by using sending some filters 'A' then 'B' and data and then 'Z' to check whether the data is receiving correctly. i use SMOD 0x50 TMOD 0x20 baud rate 9600.
in the main loop

for(i=0;i<100;i++)
                {
                        led=0x00;
                        serial_tx('A'); led=0x01;
                        serial_tx('B'); led=0x01;
                        serial_tx(i);   led=0x01;
                        serial_tx('Z'); led=0x01;
                        msdelay();
                }


in debugger when i is 0 it shows the value i=0x00; when i is 1, i=0x01...

and in the receiver same SMOD 0x50, TMOD 0x20 baud rate 9600,
in serial_read() temp=SBUF is stored

unsigned char temp, temp1, store;
while(1)
        {
                serial_read();
                if(temp=='A')
                {
                        serial_read();
                        if(temp=='B')
                        {
                                serial_read();
                                temp1=temp;
                                serial_read();
                                if(temp=='Z')
                                {
                                        P1=temp1; // data stored and sent to port1

                                }
                        }
                }
        }


here port 1 is connected with 8 led. but i am not sure of how the data sequence is being received. The lights are blinking with some randomness. Any solution regarding this. And the data sent to P1 is in binary ? Thanks in advance.

More questions in this forum