Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/24/12 22:24
Read: times


 
#187516 - More keil optimizer interesting tidbits
Responding to: ???'s previous message
Helping out the compiler is not always the best, as it turns out.

/* Uses 0x19 bytes of code */
static void put_id1(U8 id_indx, U8 id)
{
    U8 idata id_char;

    id_char = 'A' + id_indx;
    printf("<ID_%bc>%02bu</ID_%bc>n", id_char, id, id_char);
}

/* Uses 0x15 bytes of code */
static void put_id2(U8 id_indx, U8 id)
{
    printf("<ID_%bc>%02bu</ID_%bc>n", 'A' + id_indx, id, 'A' + id_indx);
}

 


Trying to be clever and pre-compute the ASCII char doesn't help the compiler at all in this case, where in my original post, it did. The only similarities I see between that situation and this is they both involve addition. Perhaps one can generalize this behavior and say that computations using addition can be inlined without additional overhead to the overall operation. It's just a guess at this point though.

List of 33 messages in thread
TopicAuthorDate
Where can one learn Intermediate C techniques for 8051            01/01/70 00:00      
   on the right track            01/01/70 00:00      
      one more thing            01/01/70 00:00      
         Not uncommon bid bad coding standards to comply with            01/01/70 00:00      
         Not afraid of globals, but...            01/01/70 00:00      
   More keil optimizer interesting tidbits            01/01/70 00:00      
      optimization            01/01/70 00:00      
      nothing gained, nothing lost            01/01/70 00:00      
         I don't            01/01/70 00:00      
            you can do both            01/01/70 00:00      
               That is not helping the compiler            01/01/70 00:00      
                  exact same            01/01/70 00:00      
                     Technically, they are not the same            01/01/70 00:00      
                        Hmmm...            01/01/70 00:00      
                        C don't do full evaluation of logical expressions            01/01/70 00:00      
                           In discrete mathematics proving one is not a proof            01/01/70 00:00      
                              Lazy evaluation demanded            01/01/70 00:00      
                                 I have learned something new because of this            01/01/70 00:00      
                                    me too            01/01/70 00:00      
                                       Very Important            01/01/70 00:00      
                              Breaks.            01/01/70 00:00      
                                 Compile the code            01/01/70 00:00      
                                    To be more exact            01/01/70 00:00      
                                       Stop It!!            01/01/70 00:00      
                                          That is exactly what I intended            01/01/70 00:00      
                                             Switch Break.            01/01/70 00:00      
               obfusciating code to help the compiler is a VERY bad idea            01/01/70 00:00      
                  the source of this            01/01/70 00:00      
   Where can one learn Intermediate C techniques for 8051            01/01/70 00:00      
   Getting the least out of your compiler            01/01/70 00:00      
      Maybe IAR should follow their own advice?            01/01/70 00:00      
         provided the case ...            01/01/70 00:00      
            Compilers not knowing the target chip.            01/01/70 00:00      

Back to Subject List