wswan:guide:optimization
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| wswan:guide:optimization [2025/12/31 12:42] – asie | wswan:guide:optimization [2025/12/31 12:50] (current) – [Optimizing for memory usage] asie | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| This page serves as a loose list of advice for getting the most out of the WonderSwan. | This page serves as a loose list of advice for getting the most out of the WonderSwan. | ||
| - | ===== Optimizing for speed ===== | + | ===== Optimizing C code ===== |
| + | |||
| + | ==== Optimizing for code speed ==== | ||
| To optimize for speed, compile your code with '' | To optimize for speed, compile your code with '' | ||
| - | ===== Optimizing for size ===== | + | ==== Optimizing for code size ==== |
| To optimize for size, compile your code with '' | To optimize for size, compile your code with '' | ||
| - | ===== Optimizing for memory usage ===== | + | ==== Optimizing for memory usage ==== |
| * 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 '' | * Exception: For argument passing, there is little reason to prefer '' | ||
| - | * 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 '' | + | * By default, GCC allows function call arguments to accumulate on the stack, then pops them all at once. To reduce |
| ===== Optimizing assembly code ===== | ===== Optimizing assembly code ===== | ||
| + | |||
| + | ==== Optimizing for speed ==== | ||
| While the V30MZ is an 80186-compatible CPU, its instruction timings differ wildly from common expectations and are more reflective of its 1990s-era design: | While the V30MZ is an 80186-compatible CPU, its instruction timings differ wildly from common expectations and are more reflective of its 1990s-era design: | ||
| Line 29: | Line 33: | ||
| You can study the instruction timings in detail on [[https:// | You can study the instruction timings in detail on [[https:// | ||
| + | |||
| + | 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 the '' | ||
| + | * Try word-aligning loop labels by prepending them with '' | ||
wswan/guide/optimization.1767184963.txt.gz · Last modified: by asie
