Another problem bring up is that:
When I tried to use the following instrution to write the code for my 89C51 chip. It can be compiled successfully. But it does not work in 8051 when I burn the code. here is the code: If(c!='A' | c!='B' | c!='O' | c!='P') { send_serial("Invalid command"); send_serial(crlf); } Look like it does not take it when I write the format like above. Why ? I cannot understand. I think Keil C Uvison can take care it.
However, if I use only one if (c!='A') { send_serial("Invalid command"); send_serial(crlf); } if (c!='B') { send_serial("Invalid command"); send_serial(crlf); } if (c!='O') { send_serial("Invalid command"); send_serial(crlf); } if (c!='P') { send_serial("Invalid command"); send_serial(crlf); } The 89C51 will recognize and run my code properly. Can you expalin what is happening?
It can be compiled successfully. But it does not work...
That compiling is ok does not impose, that the code runs like you expect it to run...
Ask yourself, if the code is ok, before pushing the blame on the tool.
First off - think about use of "and" or "or" - what is the difference?
Second - what logic operation does your second alternative use? Have you tried with both acceptable and non-acceptable characters?
... and remember that the 'C' language provides two different "and" operators, and two different "or" operators...