Home > other >  Use KEIL compile V5 C51 program, a magical thing happened...
Use KEIL compile V5 C51 program, a magical thing happened...

Time:10-10

Else if (JIN3 & amp; & F_jin3==0) {
}

Else if ((JIN3 & amp; & F_jin3==0)) {
}


This article and the following article, compilation, burn into the MCU, the execution result unexpectedly is different, there are a great god know why?
I compare the two kinds of writing compiled HEX file and LST, did not find what is the different place, it's very strange.

CodePudding user response:

The two write exactly the same, the original poster didn't write wrong?

CodePudding user response:

==priority than & amp; & High, syntax that's right, the logic is wrong, in addition, the comparison will be constant (0) in your code to the left of the==it's a good habit, at least not your problems

CodePudding user response:

refer to the second floor forget345 response:
==priority than & amp; & High, syntax that's right, the logic is wrong, in addition, the comparison will be constant (0) in your code to the left of the==it's a good habit, at least there will not be your problem

Much more is the difference between the two sentences below sentence parenthesis, two sentences are the same as the order,

CodePudding user response:

reference JSHZP reply: 3/f
Quote: refer to the second floor forget345 response:

==priority than & amp; & High, syntax that's right, the logic is wrong, in addition, the comparison will be constant (0) in your code to the left of the==it's a good habit, at least there will not be your problem

Much more is the difference between the two sentences below sentence parenthesis, two sentences is the same, the order

I know, if you want to he wants to do is JIN3 is true, and f_jin3==0,
Best can stick the execution result come out and have a look

CodePudding user response:

I tried it on

CodePudding user response:

This is a one more parentheses, machine action of execution is different,
Compiled code exactly the same,
Feel very magical,

CodePudding user response:

Test
If (f_jin3==0 & amp; & JIN3) and the if (JIN3 & amp; & F_jin3==0), the machine's action is really different, it is strange that

  • Related