#include <reg52.h> // Due to these two options, the // program always goes wrong. #pragma NOINTPROMOTE #pragma OPTIMIZE(7, SPEED) unsigned long xdata CommonValue; unsigned char xdata Result; void UseResult(void) { P3=Result; } void Func() { for (;;) { // Surely, Common Value is 100, if (CommonValue > 0L) { // Should come here Result = 0xff; } else { // But it always comes here. Result = 0; } UseResult(); } } void main(void) { CommonValue=100; Func(); }
Ignore the above message. It was posted to the wrong thread.