iccavr 使用无符号长整型使用问题
本帖最后由 lanpad 于 2012-10-21 15:47 编辑要做一个一个0-999999范围的计算
定义了无符号长整型数据类型:
#define ulint unsigned long
ulint sum;
sum = Get_hex(BS_asc)*100000 + Get_hex(BS_asc)*1000 + Get_hex(BS_asc)*100 + Get_hex(BS_asc)*10 + Get_hex(BS_asc);
Get_hex函数定义为unsigned char型,功能是取数字的ASCII码转换成16进制数:
uchar Get_hex(uint ascdata);
用ICCAVR编译时出现如下错误:
\main.c(936): internal error -- out of registers: opsize 4 free fc0ffc03 local cff003fc free&local cc000000 TN type 4 ticks 1568.
\main.c(936): internal error - movl no such register.
本来以为是不支持数据长度超过16bit的运算
可是查了查,ICCAVR应该是可以支持32bit的无符号整型的数据的呀
把函数Get_hex换成一个固定的数是可以编译通过的,例如:
sum = 4*100000 +5*1000 + 6*100 +7*10 + 8;
是什么寄存器溢出了?请问该如何解决? 本帖最后由 lanpad 于 2012-10-21 15:43 编辑
后来发现把加法分成三次可以解决编译出错的问题:
原来:
sum = Get_hex(BS_asc)*100000 + Get_hex(BS_asc)*1000 + Get_hex(BS_asc)*100 + Get_hex(BS_asc)*10 + Get_hex(BS_asc);
修改后:
sum = Get_hex(BS_asc)*100000 ;
sum = sum + Get_hex(BS_asc)*1000;
sum = sum + Get_hex(BS_asc)*100 + Get_hex(BS_asc)*10 + Get_hex(BS_asc);
……………… 变量前加(unsigned long)强制转换
页:
[1]