jtauber/dcpu16py — pull request #86 by FarMcKon (2012-04-20 00:12:24+00:00)
Title: added a couple of safty checks for some out of bounds failures

3 changes:

1) Added generator for file read, just for easier to read code using a for cmd in read_cmd(file)
2) Added a range check on op-codes to print an error, and fail
3) Added a range check on memory location to print an error, and wrap around (emulating a reasonably common chip error failure)

Questions:
Can/should we set an overflow when an unknown op is throws?
Can/should we set an overflow when an unknown or out of range mem address is hit?

I created a 'Register' class that used properties to always clip register values to a bitmask (0xFFFF in this case). If that is useful, I'll throw that in another pull request.

hack on,
- Far