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
wswan:guide:optimization [2025/12/31 12:50] – [Optimizing for memory usage] asiewswan:guide:optimization [2026/02/11 18:53] (current) asie
Line 38: Line 38:
   * 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.   * 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.
 +
 +===== Measuring programs =====
 +
 +==== Measuring code size ====
 +
 +Wonderful Toolchain comes with a tool for observing the RAM/ROM allocation and per-symbol sizes: ''%%wf-wswantool usage build/your_program.elf%%''. It is also provided in the default Makefile as ''%%make usage%%''.
 +
 +==== Measuring performance ====
 +
 +The best option is to use Mesen 2's profiler. While Mesen 2 is not 100% cycle-accurate for the WonderSwan yet, it's close enough for non-demoscene use cases.
 +
 +TODO: Document how to use it.
wswan/guide/optimization.1767185434.txt.gz · Last modified: by asie