Forum : ST7/STM8
Original Post
Post Information | Post |
---|---|
October 19, 2009 - 3:01pm
|
The following code: unsigned char RxBuf[17]; short _Balance[6]; short _PeakP[6]; short WIP_Balance[6]; void ParseBalanceData(void); int main(void) { ParseBalanceData(); } void ParseBalanceData(void) { unsigned char ptr = RxBuf[0]*3; short bal; bal = (RxBuf[2] << 8) | (RxBuf[3]); if (_PeakP[ptr] < bal) _PeakP[ptr] = bal; _Balance[ptr] = (WIP_Balance[ptr]) >> 4; WIP_Balance[ptr] -= _Balance[ptr]; WIP_Balance[ptr] += bal; } Uses the Y register for line 22 "WIP_Balance[ptr] -= _Balance[ptr];", but incorrectly initializes it (uses tye value held in A, instead of the one already in X. 0058 BE00 F LD X,ptr 005A 58 SLL X 005B 9097 LD Y,A 005D D6002A F LD A,(WIP_Balance + 01H,X) 0060 90D00012 F SUB A,(_Balance + 01H,Y) 0064 88 PUSH A 0065 D60029 F LD A,(WIP_Balance + 00H,X) 0068 90D20011 F SBC A,(_Balance + 00H,Y) 006C D70029 F LD (WIP_Balance + 00H,X),A 006F 84 POP A 0070 D7002A F LD (WIP_Balance + 01H,X), For now i'm using #pragma ot(5), which removes the issue but produces some really ugly output 00A2 B600 F LD A,ptr 00A4 48 SLL A 00A5 3F03 F CLR ?BH 00A7 3F04 F CLR ?BL 00A9 B704 F LD ?BL,A 00AB B604 F LD A,?BL 00AD 97 LD X,A 00AE B604 F LD A,?BL 00B0 9097 LD Y,A Hopefully this will be fixed in the next version? -- |
Hi Blasio,
Thansk for this detailed report. We reproduced the problem in our labs. It is indeed cause by an erroneous optimization in the peephole -- OT(7).
It will be fixed in the next RKit-STM8 release.
REgards,
Bruno