Warning

You're browsing the old v2.x documentation. This version is no longer maintained. Click here to go the v3.x documentation.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
performance [2019/08/01 12:26] – [Tip #6: use ON for branching] neilsperformance [2019/08/05 11:47] – [Tip #8 REPEAT ... UNTIL is faster than FOR ... NEXT] neils
Line 82: Line 82:
   on x! goto false_case, true_case   on x! goto false_case, true_case
  
-==== Tip #REPEAT ... UNTIL is faster than FOR ... NEXT ====+==== Tip #REPEAT ... UNTIL is faster than FOR ... NEXT ====
  
 You can gain some speed boost using ''REPEAT ... UNTIL'' instead of  ''FOR ... NEXT'': You can gain some speed boost using ''REPEAT ... UNTIL'' instead of  ''FOR ... NEXT'':
Line 97: Line 97:
     inc i!     inc i!
   until i! = 100   until i! = 100
 +  
 +==== Tip #9: Know the optimizer ====
 +
 +**XC=BASIC** features a built-in optimizer that replaces commonly used program sequences with faster opcode sequences. To make good use of the optimizer, bear in mind the following program structures that can be optimized:
 +
 +  * Value assignment of bytes and integers
 +  * Addition of bytes and integers
 +  * Subtraction of bytes and integers
 +  * Comparison of bytes, e. g. ''IF x! > 5 THEN ...''
 +  * ''IF'', ''WHILE'' and ''UNTIL'' statements with byte type comparison as condition, e .g ''WHILE x! <= 255''
 +  * Array access of byte type arrays with byte type index
 +  * Bitwise operators on bytes
 +  * POKE and PEEK (they're the fastest when using constant addresses)
 +
 +The following are not optimized at all:
 +
 +  * Operations on floating point types
 +  * I/O commands like ''PRINT'', etc.
 +  * Convenience commands like ''TEXTAT''