Skip to content

Instantly share code, notes, and snippets.

@hawkw
Created December 5, 2013 21:47
Show Gist options
  • Save hawkw/7814533 to your computer and use it in GitHub Desktop.
Save hawkw/7814533 to your computer and use it in GitHub Desktop.
actual source code comment that I actually wrote (I am sorry)
/*
* Generates semi-optimizing moves for the MarsBot based on the next move and the current position.
*
* By semi-optimizing, I mean that relative moves are computed at compile-time rather than at runtime.
* This adds a little extra complexity to the code generation program (in that it has to track the
* MarsBot's current position), but significantly reduces the complexity of the resulting MIPS program,
* removing the necessity to do two memory-access operations (to get the MarsBot's navigational data)
* at runtime.
*
* This function outputs programmatically generated MIPS instructions to the destination file stream,
* using the MIPS instructions defined in MIPSCodeGen.h. It also returns a point containing the
* ordered pair of the location to which the move will take the MarsBot, to facilitate the optimizing
* code generation I mentioned above.
*
* N.B that I refer to this code-generation scheme as "semi-optimizing" because if I really wanted to
* make the most efficient possible MIPS code, I would not use the horiz and vert functions for diagonal
* moves. Instead, I would compute headings using C trig functionality and move directly to the required
* point for each move instead. This kind of code-generation might be added to this program at a later date.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment