[cc65] A Few Good Optimizations

From: <maspethrose71aol.com>
Date: 2010-11-12 17:20:54
I have a few good optimizatios for code written in cc65 C:

*    Declaring an auto variable as static can save code.
*    Register declarations can save space in functions that don't call other functions.
*    If you need a certain calculation performed on the same piece of data several times, calculate it once and assign it to a variable.  If on several pieces of data at different times, write a function from that calculation and call it as needed.
*    If you need to call a function with the same parameters several times, create a wrapper function to supply the repeated parameters and call it with only the variant parameters.
*    If you need to reference a certain member of a struct or element of an array such that it takes extra calculations to access it, create a pointer to it or copy it to a static variable, a pointer if you need to modify it and a static variable if yoyu just need use the data.
*    If you use a function that will return the same value in your target and offers no other functionalite, try defining it as a const or using #define.
*    Using simpler functions usually saves code.

In exchange for these, I ask the following:

*    That these optimizations be placed in cc65's documentation,
*    That I be honored with these optimizations :), and
*    That others post their optimizations here.
--------------------
Joseph Rose, a.k.a. Harry Potter
Working magic in the computer community...or at least striving to!  :(

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Nov 12 17:21:17 2010

This archive was generated by hypermail 2.1.8 : 2010-11-12 17:21:20 CET