Refactor opcodes a bit.

Opcodes now take in get/write functions to handle retrieving and writing
values that they operate on. Reduces code duplication and makes debug
logging a little more convenient.