|
发表于 2011-3-7 21:53:06
|
显示全部楼层
以下是ChibiOs 开发人员发现cosmic 4.3.4 的bug,cosmic 技术员也承认了,说是下一版本已修复此问题,即v4.3.5
Hello,
I am working on a ChibiOS/RT port on the Cosmic STM8 compiler, everything seems to work except a problem I found in the queues subsystem, the problem seems to be related to the compiler. I created a minimal code sample, the original code is way too complex for a report:
struct aaa {
unsigned char *p1;
unsigned char *p2;
int cnt;
};
int ccc(struct aaa *p) {
if (p->cnt >= (p->p2 - p->p1))
return -3;
return 0;
}
The generated code is:
94 0000 _ccc:
98 ; 32 if (p->cnt >= (p->p2 - p->p1))
100 0000 9c rvf
101 0001 9093 ldw y,x
102 0003 90ee02 ldw y,(2,y)
103 0006 fe ldw x,(x) <===== X modified
104 0007 bf00 ldw c_y,x
105 0009 72b20000 subw y,c_y
106 000d 90bf00 ldw c_y,y
107 0010 9093 ldw y,x <===== X assumed not modified
108 0012 90ee04 ldw y,(4,y)
109 0015 90b300 cpw y,c_y
110 0018 2f04 jrslt L74
111 ; 33 return -3;
113 001a aefffd ldw x,#65533
116 001d 81 ret
117 001e L74:
118 ; 34 return 0;
120 001e 5f clrw x
123 001f 81 ret
The code has been compiled without optimizations and in debug mode:
cxstm8 -i..\..\..\test +modsl0 +debug -pxp -no -pp -l -i..\..\..\os\hal\include -i..\..\..\os\hal\platforms\stm8 -i..\..\..\boards\st_stm8s_discovery -i..\..\..\os\ports\cosmic\stm8 -i..\..\..\os\kernel\include -i"C:\Program Files\COSMIC\CXSTM8_32K\Hstm8" -clDebug\ -coDebug\ main.c
This post is not about searching for a workaround but the following seems to work:
if ((p->p2 - p->p1) <= p->cnt)
I hope it is not a mistake on my side :-) am I missing something obvious?
Giovanni
---
ChibiOS/RT http://chibios.sourceforge.net
Hi,
this is a problem in the compiler. It is now fixed and the fix will be available in the next release.
Regards,
Luca (Cosmic) |
|