This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

A compiler bug of Keil C V6.21

#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();
}


0