my first Q is, while simulating in KEIL does it not able to read the SBUF. when i am simulating the program and i make RI high then it goes to the intrupet and then put SBUF= any value like SBUF='s' and then the cursor goes to my reading line i.e var=SBUF; but after this there is no value in var and one more thing if the var has some value before var=SBUF; it goes zero all gone . so now i am doubting keil simulator. but my transmit part is working fine.
so now i am doubting keil simulator.
There's no reason to. From what you describe, the simulator is working exactly as it should be. You need to refer to the 8051 hardware documentation for the exact explanation.
SBUF does _not_ act like a regular register. You cannot read a value back from it. If you read from SBUF, you will read the last value received by the UART (if any), not the last value you wrote to SBUF.
also referred to as the "bible" for the 8051:
www.8052.com/.../120112
See also: www.8052.com/.../tutorial
and: http://www.8052.com/faqs (there is a whole section on serial comms)
Hmm... try this instead: http://www.8052.com/tutorial
You _write_ to SBUF with the intention to send something out.
To be able to _read_ from SBUF, the serial port must have _received_ something from outside.
SBUF is one read-only register mapped to the same address as one write-only register. Same in simulator and actual hardware. Same in quite a number of processors, since it isn't meaningful to try to catch what character you have already dropped off to send.
When you drop a letter into the narrow mail box slot, you are not indented to be able to get it back and get a second view of it either..