User Tools

Site Tools


wswan:guide:optimization

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
wswan:guide:optimization [2025/12/31 12:49] asiewswan:guide:optimization [2025/12/31 12:50] (current) – [Optimizing for memory usage] asie
Line 17: Line 17:
   * For data stored in RAM, use the smallest type possible.   * For data stored in RAM, use the smallest type possible.
     * Exception: For argument passing, there is little reason to prefer ''%%char%%'' over ''%%int%%'' - the stack is always aligned to 2 bytes.     * Exception: For argument passing, there is little reason to prefer ''%%char%%'' over ''%%int%%'' - the stack is always aligned to 2 bytes.
-  * By default, GCC allows function call arguments to accumulate on the stack, then pops them all at once. To reduce stack usage at the cost of a larger and slightly slower program, compile your code with ''%%fno-defer-pop%%''.+  * By default, GCC allows function call arguments to accumulate on the stack, then pops them all at once. To reduce peak stack usage at the cost of a larger and slightly slower program, compile your code with ''%%-fno-defer-pop%%''.
  
 ===== Optimizing assembly code ===== ===== Optimizing assembly code =====
Line 36: Line 36:
 There are also some additional tricks you can take advantage of: There are also some additional tricks you can take advantage of:
    
-  * Avoid far calls between functions - branches are expensive, and far branches are significantly more expensive. If you're calling a far function from another far function in the same section, use ''%%IA16_CALL_LOCAL%%'' over ''%%IA16_CALL%%'' to save a few cycles.+  * Avoid far calls between functions - branches are expensive, and far branches are significantly more expensive. If you're calling a far function from another far function in the same section, use the ''%%IA16_CALL_LOCAL%%'' macro over a far call to save a few cycles.
   * Try word-aligning loop labels by prepending them with ''%%.align 2, 0x90%%'' - this generates a NOP opcode if necessary. This may help a little.   * Try word-aligning loop labels by prepending them with ''%%.align 2, 0x90%%'' - this generates a NOP opcode if necessary. This may help a little.
wswan/guide/optimization.1767185366.txt.gz · Last modified: by asie