Harjit Singh

Codewright V6.2, build 8127; Coldfire MCF51JM128; Code generation bugs?

Discussion created by Harjit Singh on Jul 30, 2008
Latest reply on Jul 31, 2008 by CompilerGuru
I'm trying to initialize two bit variables and I'm seeing it init the first bit variable properly and then when it goes to init the second bit variable, it clears the first one. I think the BCLR at 0x4C shouldn't be there.
 
;  238:   RGPIO_ENB_ENB0 = RGPIO_ENB_ENB1 = 1;    // enable the two lower bits
;  239:     
;
0x00000036  0x303900C00004           move.w   0x00c00004,d0
0x0000003C  0x08C00001               bset     #1,d0
0x00000040  0x33C000C00004           move.w   d0,0x00c00004
0x00000046  0x303900C00004           move.w   0x00c00004,d0
0x0000004C  0x08800000               bclr     #0,d0
0x00000050  0x08C00000               bset     #0,d0
0x00000054  0x33C000C00004           move.w   d0,0x00c00004
 
In an interrupt routine, I'm trying to toggle a line and I'm seeing a BCLR instruction instead of a BSET at 0x00000008 below - Ignore the fact that I'm not clearing the interrupt, etc.:

;  388: interrupt VectorNumber_Vrtc void   RTC_ISR(void) {
;  388:                                                  {
;
0x00000000                    _RTC_ISR:
;                             RTC_ISR:
0x00000000  0x2F00                   move.l   d0,-(a7)
;
;  389:   RGPIO_TOG_TOG1 = 2;
;  390:   
;  391:   #if 0
;  392:     if (some_key_pressed) {
;  393:        RTCMOD = 0x01;                       // set period 10ms
;  394:        RTCSC  = 0x0B;                       // Disable RTIE
;  395:        key_press_debounced = yes;
;  396:     }
;  397:     RTCSC_RTIF = 1;                         // clear flag
;  398:   #endif
;  399:   
;
0x00000002  0x303900C0000E           move.w   0x00c0000e,d0
0x00000008  0x08800001               bclr     #1,d0
0x0000000C  0x33C000C0000E           move.w   d0,0x00c0000e
;
;  400: }
;
0x00000012  0x201F                   move.l   (a7)+,d0
0x00000014  0x4E73                   rte     

Help!

Harjit

Outcomes