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

problem adding integer

why result different?

sample 1:

unsigned int index;

char getch()
{
while (!RI);
RI = 0;
return SBUF;
}

index = getch();
index += getch() * 0x0100;

serial port received 2 bytes which are same 0xE8 and result in index is 0xE7E8.

sample 2:

unsigned char ww;

ww = getch;
index = ww;
ww = getch;
index += ww * 0x0100;

result is 0xE8E8.

Parents Reply Children
No data