From 8889bd84ac05394e2612fe4d4ada605efe2dff36 Mon Sep 17 00:00:00 2001 From: Murad Karammaev Date: Sun, 14 Aug 2022 03:33:41 +0300 Subject: [PATCH] add 'print_opcodes' binary --- Makefile | 8 ++++++++ toy_cpu_4bit/Cargo.toml | 3 +++ toy_cpu_4bit/examples/print_opcodes.rs | 7 +++++++ 3 files changed, 18 insertions(+) create mode 100644 toy_cpu_4bit/examples/print_opcodes.rs 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)); + } +}