[PRL] code size optimization via tail call elimination

Doug Orleans dougorleans at gmail.com
Fri Apr 29 17:07:41 EDT 2011


I've been slowly making my way through the GDC Vault:

http://www.gdcvault.com/free/gdc-11

Specifically, the videos of post-mortem talks about classic video games.  My
favorite so far is Will Wright (of Sims and Spore fame) talking about his
first game, Raid on Bungeling Bay, written in 1984 for the Commodore 64.  At
one point he talks about optimizing the memory footprint of the game, since
he only had about 60k to work with.  What amused me was that his example for
how to pick up a byte here and there was to look for a sequence of JSR (jump
to subroutine) immediately followed by RTS (return from subroutine) and
replacing it with a single JMP instruction.  In other words, he did tail
call elimination, not to conserve stack space, but to conserve code size!

--Doug
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the PRL mailing list