| Alban | 2006-08-31 10:16 AM |
There has never been any problem reported with this procedure I use daily to correct code un-correctly posted.
is in the editor toolbar.
Regards,
Alban.
Message Edited by Lundin on 2007-02-1401:15 PM
Lundin wrote:
The thing is, the optimizer was the one who decided to remove 0x300 from the id variable and store the result in acc D. Then further down, it decides to use
D - 0 which is indeed equal to id - 0x300.
And then it complains subraction with zero.
Creepy, unexpected warnings like this make me nervous and make me suspect that the "tree optimizer" isn't tested properly. Creepier still, setting all variables involved to volatile doesn't help. To be on the safe side, I think I'll disable this optimizer option for all my projects.
---
80: if(id >= DCAN_MSG_FEEDBACK0 && 0002 830300 [2] SUBD #768 0005 8c001f [2] CPD #31 0008 2204 [3/1] BHI *+6 ;abs = 000e 81: id < (DCAN_MSG_FEEDBACK0+FEEDBACK_MSG_N)) 82: { 83: 84: dsip_id = (unsigned char)(id - DCAN_MSG_FEEDBACK0); /* WARNING C5906 */ 000a e681 [3] LDAB 1,SP 000c 6b82 [2] STAB 2,SP 85: }
81: if(id >= DCAN_MSG_FEEDBACK0 && 0001 fc0000 [3] LDD id 0004 8c0300 [2] CPD #768 0007 250d [3/1] BCS *+15 ;abs = 0016 82: id < (DCAN_MSG_FEEDBACK0+FEEDBACK_MSG_N)) 0009 fc0000 [3] LDD id 000c 8c0320 [2] CPD #800 000f 2405 [3/1] BCC *+7 ;abs = 0016 83: { 84: 85: dsip_id = (unsigned char)(id - DCAN_MSG_FEEDBACK0); /* WARNING C5906 */ 0011 f60000 [3] LDAB id:1 0014 6b80 [2] STAB 0,SP
Lundin wrote:
(Assuming a 8-bit access and a 16-bit access gives the same result. I can't remember if there is some case on the HCS12 where it doesn't, but when it comes to timer registers and similar, I'm not so sure.)