i = i + OFFS + 3;
</verb></tscreen>
-The expression is parsed from left to right, that means, the compiler sees
-'i', and puts it contents into the secondary register. Next is OFFS, which is
+The expression is parsed from left to right, that means, the compiler sees 'i',
+and puts it contents into the secondary register. Next is OFFS, which is
constant. The compiler emits code to add a constant to the secondary register.
-Same thing again for the constant 3. So the code produced contains a fetch of
-'i', two additions of constants, and a store (into 'i'). Unfortunately, the
+Same thing again for the constant 3. So the code produced contains a fetch
+of 'i', two additions of constants, and a store (into 'i'). Unfortunately, the
compiler does not see, that "OFFS + 3" is a constant for itself, since it does
it's evaluation from left to right. There are some ways to help the compiler
to recognize expression like this:
</enum>
-<sect>Case labels in a switch statments are checked in source order<p>
-
-Labels that appear first in a switch statement are tested first. So, if your
-switch statement contains labels that are selected most of the time, put them
-first in your source code. This will speed up the code.
-
-
-
<sect>Use the preincrement and predecrement operators<p>
The compiler is not always smart enough to figure out, if the rvalue of an
-<sect>When using the <tt/?:/ operator, cast values that are not ints<p>
+<sect>When using the ternary operator, cast values that are not ints<p>
The result type of the <tt/?:/ operator is a long, if one of the second or
third operands is a long. If the second operand has been evaluated and it was
restore the values - you need to make heavy use of a variable to justify the
overhead.
-An exception are pointers, especially char pointers. The optimizer has code to
-detect and transform the most common pointer operations if the pointer
-variable is a register variable. Declaring heavily used character pointers as
-register may give significant gains in speed and size.
+As a general rule: Use register variables only for pointers that are
+dereferenced several times in your function, or for heavily used induction
+variables in a loop (with several 100 accesses).
+
+When declaring register variables, try to keep them together, because this
+will allow the compiler to save and restore the old values in one chunk, and
+not in several.
-And remember: Register variables must be enabled with <tt/-Or/.
+And remember: Register variables must be enabled with <tt/-r/ or <tt/-Or/.
Since cc65 has the "wrong" calling order, the location of the fixed parameters
in a variadic function (a function with a variable parameter list) depends on
the number and size of variable arguments passed. Since this number and size
-is unknown at compiler time, the compiler will generate code to calculate the
+is unknown at compile time, the compiler will generate code to calculate the
location on the stack when needed.
Because of this additional code, accessing the fixed parameters in a variadic