void main() { unsigned int a1; unsigned int b1; unsigned char h; unsigned char l; a1=0xab12; l=a1; b1=(a1&0xff00)/256; h=b1; }
用KEIL调试时发现,a1变量中的值没有赋成ab12h,而只是赋成0012h.程序改成如下后,a1的赋值就正确了:
void main() { unsigned int a1; unsigned int b1; unsigned char h; unsigned char l; a1=0xab12; l=a1; a1=a1>>8; h=b1; } 请问这是什么原因呢? |