Skip to content

Instantly share code, notes, and snippets.

@duckinator
Last active October 10, 2016 07:11
Show Gist options
  • Save duckinator/7400477dc8262532feab20f819a19b94 to your computer and use it in GitHub Desktop.
Save duckinator/7400477dc8262532feab20f819a19b94 to your computer and use it in GitHub Desktop.
let mut methods = std::collections::HashMap::new();
methods.insert(0b0000, mov);
methods.insert(0b0001, add);
methods.insert(0b0010, nand);
// ...
fn execute(opcode: u8, operand1: u8, operand2: u8) {
methods.get(opcode)(operand1, operand2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment