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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,851 Views
Harjit
Contributor II
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

Labels (1)
0 Kudos
Reply
2 Replies

646 Views
Harjit
Contributor II
On the second problem, I've got the wrong write value. It should be 0 or 1. The first one still seems wrong.
 
Thanks,
Harjit
0 Kudos
Reply

646 Views
CompilerGuru
NXP Employee
NXP Employee
The BCLR at 0x4C does not need to be there, but having it is not wrong, just inefficient.
I would suggest that you file a service request to improve this, so it does get better in a future releases.

Also note that

RGPIO_ENB_ENB0 = RGPIO_ENB_ENB1 = 1;
is not the same as
RGPIO_ENB_ENB0 = 1;
RGPIO_ENB_ENB1 = 1;
(its more like

  RGPIO_ENB_ENB1 = 1;
RGPIO_ENB_ENB0 = RGPIO_ENB_ENB1;
)
but as those are all volatile accesses the compiler does not optimize that much.
I would suggest to assign 1 to all variables in general, even independently of how the compiler generates the code.

Daniel

0 Kudos
Reply