diff --git a/Makefile b/Makefile index b5a0e80..5fdfdf9 100644 --- a/Makefile +++ b/Makefile @@ -15,3 +15,11 @@ unit-tests: acceptance-tests: build @acceptance-tests/main.py + + +# Examples + +.PHONY: print_opcodes + +print_opcodes: + @cargo run --example print_opcodes diff --git a/toy_cpu_4bit/Cargo.toml b/toy_cpu_4bit/Cargo.toml index 902c4cd..fd4a9de 100644 --- a/toy_cpu_4bit/Cargo.toml +++ b/toy_cpu_4bit/Cargo.toml @@ -7,3 +7,6 @@ edition = "2021" ux = "0.1.3" regex = "1.5.4" lazy_static = "1.4.0" + +[[example]] +name = "print_opcodes" diff --git a/toy_cpu_4bit/examples/print_opcodes.rs b/toy_cpu_4bit/examples/print_opcodes.rs new file mode 100644 index 0000000..bd7ebe1 --- /dev/null +++ b/toy_cpu_4bit/examples/print_opcodes.rs @@ -0,0 +1,7 @@ +use toy_cpu_4bit::instruction::decode; + +fn main() { + for i in 0..=255 { + println!("{:#04X}\t{:#010b}\t{:?}", i, i, decode(i)); + } +}