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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/16/07 16:10
Modified:
  05/16/07 16:19

Read: times


 
#139367 - My Two Cents
Responding to: ???'s previous message
You're on the right track by putting your variables in the "data" and "idata" segments whenever possible.

Some other hints:
  • Play around a little bit by writing the same program in different ways. Look at the generated code to see what works best with your compiler. For example, you can write an endless loop in lots of different ways:
    while (1) { /* Loop body here */ }
    for (;;) { /* Loop body here */ }
    do { /* Loop body here */ } while (1); 
    or even (*gasp*)
    LoopTop:
    /* Loop body here */
    goto LoopTop;
    Try them all and see which generates the best code. Then do similar experiments for other constructs that you use frequently. Eventually you will get a gut feel for how your compiler works.
  • Use the smallest data type that will do the job. In other words, don't use an 'int' if all you need is a 'char'.
  • Similarly, don't use floating point arithmetic if you can somehow use integers instead.
Others will have many more hints, I'm sure.

One more thing ... as in most things, there are tradeoffs here. Don't worry so much about "efficiency" that you forget other important things like maintainability and readability and portability. Execution speed can be important, but it is usually so only in a few "hot spots" within any given program. Reserve your tricks for those places (assembly language might be the best trick, by the way), and use your energy elsewhere to make your programs easy to read and maintain.

-- Russ


List of 43 messages in thread
TopicAuthorDate
How to speed code?            01/01/70 00:00      
   How did you come to that bizarre idea...            01/01/70 00:00      
      bizarre!?            01/01/70 00:00      
         I am a C-hater, remember...            01/01/70 00:00      
      Smaller, Faster            01/01/70 00:00      
   Is that true??            01/01/70 00:00      
   Often mutually exclusive...            01/01/70 00:00      
   Take my contribution with a grain of salt.            01/01/70 00:00      
      http://www.8052.com/users/disasm/            01/01/70 00:00      
   what compiler?            01/01/70 00:00      
   Data types            01/01/70 00:00      
   Getting the least            01/01/70 00:00      
   My Two Cents            01/01/70 00:00      
      Turn in your Programmer's ID Card.            01/01/70 00:00      
         heheh...yeah            01/01/70 00:00      
         SJMP            01/01/70 00:00      
   Comments            01/01/70 00:00      
   How to speed code?            01/01/70 00:00      
   a couple of \'rules\'            01/01/70 00:00      
      More on Erik's Rules            01/01/70 00:00      
         a comment            01/01/70 00:00      
         PDATA            01/01/70 00:00      
            don't forget about @DPTR access to CDATA            01/01/70 00:00      
               but            01/01/70 00:00      
                  WHAT??? You mean I have it too? Dystypia?            01/01/70 00:00      
                     Enginnering is all about the tradeoffs            01/01/70 00:00      
                        two places where you REALLY can make an impact            01/01/70 00:00      
                           b) buffer at 256 byte boundary            01/01/70 00:00      
                              Alignment            01/01/70 00:00      
                              you did'nt hear ?            01/01/70 00:00      
               Another \"but\"            01/01/70 00:00      
                  it is, after all, quicker            01/01/70 00:00      
                     Errr...            01/01/70 00:00      
                        perhaps, but it has to "live" somewhere.            01/01/70 00:00      
                           You\'re assuming...            01/01/70 00:00      
                              confirming Andys statement            01/01/70 00:00      
                                 We WERE discusisng 805x ...            01/01/70 00:00      
                                    well, does it not?            01/01/70 00:00      
                                       Tables in code space vs data space            01/01/70 00:00      
                                          Philps XA, the best "16 bit '51"            01/01/70 00:00      
                                             Maxim/Dallas DS89C450            01/01/70 00:00      
   most compilers            01/01/70 00:00      
      Thanks            01/01/70 00:00      

Back to Subject List