指令(u16)(((u16)TIM1-> CNTRH<< 8)|(u16)(TIM1-> CNTRL))
在我看来有两侧左侧和右侧和编译器根据其转换为组装的规则将从右侧或左侧开始,或者在这种情况下它从右侧开始。
所以我认为最好将这条指令分成两条指令:
u16 uiTemp;
uiTemp =(u16)TIM1-> CNTRH<< 8);
uiTemp | =(u16)(TIM1-> CNTRL);
返回uiTemp;
它有点长,但它不会导致错误的阅读顺序
再见
以上来自于谷歌翻译
以下为原文
the instruction (u16)(((u16)TIM1->CNTRH << 8) | (u16)(TIM1->CNTRL))
In my opinion has Two side the left side and Right side and the compiler according to its rules of converting to assembly will begin from the right or from the left, in or case here it begin from the right.
So I think it's better to seperate this instruction in two instructions :
u16 uiTemp;
uiTemp = (u16)TIM1->CNTRH << 8);
uiTemp |= (u16)(TIM1->CNTRL);
return uiTemp;
it's a little bit long but it don't cause a wrong reading sequence
ciao
指令(u16)(((u16)TIM1-> CNTRH&lt;&lt; 8)|(u16)(TIM1-> CNTRL))
在我看来有两侧左侧和右侧和编译器根据其转换为组装的规则将从右侧或左侧开始,或者在这种情况下它从右侧开始。
所以我认为最好将这条指令分成两条指令:
u16 uiTemp;
uiTemp =(u16)TIM1-> CNTRH&lt;&lt; 8);
uiTemp | =(u16)(TIM1-> CNTRL);
返回uiTemp;
它有点长,但它不会导致错误的阅读顺序
再见
以上来自于谷歌翻译
以下为原文
the instruction (u16)(((u16)TIM1->CNTRH << 8) | (u16)(TIM1->CNTRL))
In my opinion has Two side the left side and Right side and the compiler according to its rules of converting to assembly will begin from the right or from the left, in or case here it begin from the right.
So I think it's better to seperate this instruction in two instructions :
u16 uiTemp;
uiTemp = (u16)TIM1->CNTRH << 8);
uiTemp |= (u16)(TIM1->CNTRL);
return uiTemp;
it's a little bit long but it don't cause a wrong reading sequence
ciao
举报