Topic : RKit-STM8 2.32.10.0307 - JRSGE usage problem

Forum : ST7/STM8

Original Post
Post Information Post
February 8, 2011 - 12:35pm
Guest

Hello everybody,

here's a problem I discovered after the upgrade from RKit-STM8 Version 2.26.09.0317 to Version 2.32.10.0307.
The following "if" statement is not correctly executed:

if(UART1_RX_Index < UART1_RX_BUFFER_SIZE)

Here's the variable definitions:

unsigned char UART1_RX_Index;
#define UART1_RX_BUFFER_SIZE 134

When the "UART1_RX_Index" has a zero value, the test is (wrongly) negative, instead of (correctly) positive.
This is the compiler listing:

C60000 LD A,UART1_RX_Index
A186 CP A,#086H
2E1A JRSGE 0E866H

The compiler uses the JRSGE instructionj instead of the JRNC, and this seems to originate the problem.
After some tryout I changed the code as follows (just adding a cast):

if((u16)UART1_RX_Index < (u16)UART1_RX_BUFFER_SIZE)

The compiler listing changed as follows:

C601EA LD A,UART1_RX_Index
A186 CP A,#086H
241A JRNC 0E866H

The JRNC is correctly used, and the software flow is correct.

I'm now thinking about downgrading the RKit-STM8, since it seems to be a compiler bug.
Is my guess correct?
Any help will be appreciated.

Thank You,

Lorenzo.

Replies
Post Information Post
+1
0
-1
February 8, 2011 - 4:44pm
Raisonance Support Team

Hi Lorenzo,

Thanks for this report.
We have had this problem in the past, so I am surprised that you have it with our latest release.

Unfortunately, we have not been able to reproduce the problem in our Labs.
Can you send us your compiler listing file? This would help us understanding the root cause of your problem.

Best Regards,

+1
0
-1
February 8, 2011 - 5:05pm
Guest

Hi Bruno,

The file is part of a project that my copany (EFI Technology s.r.l.) sold to a customer, let me inform about the possibility of any problem in giving the file.

In the meantime I by-passed the problem lowering the optimization level.

I can confirm that the problem is present for sure with optimizazion level 3 (preference Speed), and that it's not present for sure with optimization level 0 (preference Speed).

I have no reliable information about levels 1 and 2 yet.

Hope this could help...as soon as I can I'll post you the compiler listing file.

Thanks

+1
0
-1
February 8, 2011 - 5:28pm
Guest

Hi Bruno,

I've seen that the problem is present just with optimization level 3.
I can give you the compiler listing file, but it's too big to post it here (110KB).
How can I give it to you?

Regards

+1
0
-1
February 11, 2011 - 11:18am
Raisonance Support Team

Hi Lorenzo,

Thanks for your efforts on this topic.

Thanks to your listing files, we have sucessfully reproduced the problem in our labs. It comes from an invalid behavior in the compiler peephole optimizer.

We will fix this bug in the next RKit-STM8 (due early March).

In the meantime, the easy workaround is to keep the optimization level to o(2) for the failing file.

Best Regards,

+1
0
-1
February 11, 2011 - 12:21pm
Guest

Thank You Bruno.

Best Regards,

Lorenzo.