2013-03-04 07:33 AM
I'm using Cosmic Eval C Compiler V 4.3.7.
The code of concern is as follows: if( RST->SR & (u8)0x02 == (u8)0x02) {....} I'm simply checking bit 1 of the reset register. I checked the disassembler because the program was not working as expected and this is what I found: main.c:215 if( RST->SR & (u8)0x02 == (u8)0x02){ 0x9272 <.ckResetForIWDG+12> 0xC650B3 LD A,0x50b3 LD A,0x50b3 0x9275 <.ckResetForIWDG+15> 0xA501 BCP A,#0x01 BCP A,#0x01 0x9277 <.ckResetForIWDG+17> 0x275F JREQ 0x92d8 .....} This is clearly why my program will not work as expected, the disassembler tells me that I'm checking bit 0 not bit 1! Am I missing something?2013-03-04 10:32 AM
I found a work around by using a temp variable to store the result of the AND and compare using the temp variable. However, as far as I know my original bit of code was legal C...
2013-03-05 01:40 AM