Keith Hamberg

Generated Assembly Code Inefficent

Discussion created by Keith Hamberg on Aug 23, 2007
Latest reply on Aug 23, 2007 by CompilerGuru
Hi

I am using Metrowerks v6.4 compiling C code. I looked through the message board for a similar post and did not find one. My apoligies if this has already been discussed. This is for a 5270 micro, optimization level2 (doesn't matter as long as it is not level 0 ). My quesion is: Is there a way to get Metrowerks to generate for example (a0)+ (emphasis on the +) instruciton when imcrementing pointers?

Thank you.


I have this simple code (snippet)

char *ascii_data = cpe.data ;  //(cpe.data is a structure array of 400 chars )

   *ascii_data++  = '0' ;  // Group
   *ascii_data++  = '1' ;  // Duration
   *ascii_data++  = '1' ;  // default on pattern
   *ascii_data++  = '1' ;  // default of pattern

I would expect something like this generated

move.b d1, (a0)+
move.b d0, (a0)+
move.b d0, (a0)+
move.b d0, (a0)+



I get this:

  779:    *ascii_data++  = '0' ;  // Group
;
0x000001B6  0x204E                   movea.l  a6,a0
0x000001B8  0x528E                   addq.l   #1,a6
0x000001BA  0x1081                   move.b   d1,(a0)
;
;  780:    *ascii_data++  = '1' ;  // Duration
;
0x000001BC  0x204E                   movea.l  a6,a0
0x000001BE  0x528E                   addq.l   #1,a6
0x000001C0  0x1080                   move.b   d0,(a0)
;
;  781:    *ascii_data++  = '1' ;  // default on pattern
;
0x000001C2  0x204E                   movea.l  a6,a0
0x000001C4  0x528E                   addq.l   #1,a6
0x000001C6  0x1080                   move.b   d0,(a0)
;
;

====================



Outcomes