Talk:How I write Uzebox Games

From Uzebox Wiki
Jump to navigation Jump to search

There are some problems with this list:

  • 3. Minimize local variables. This doesn't pay off. The AVR has lots of registers, GCC won't allocate stack space unless necessary. It is true that stack usage depends on the amount of local variables, but the relation is more complex than this due to the calling convention. Locals have the huge advantage that they reuse memory (the stack) across functions which isn't true for globals. Usually it is better to increase stack space than attempting to make things global hoping to trim stack usage down.
  • 6. Multiply on the AVR is cheap and shifts are relatively expensive, it is best to leave the compiler deciding how to carry out a multiply with constant (sometimes shifting and adding is more optimal, sometimes multiplying). It is best to write these parts according to the actual mathematical intention (code readability). Division however needs care (the AVR has no HW divider), shifting is cleaner there to force the intention of not attempting to perform an actual division.
  • 7. Decimal conversions can be done without divisions relatively fast [1].