diff --git a/src/instruction.rs b/src/instruction.rs index fcb2399..ee8e4b9 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -1,5 +1,5 @@ use super::cpu::{Cpu, Flags, Register, RegisterPair}; -use std::convert::TryFrom; +use std::{convert::TryFrom, fmt::Debug}; #[derive(Debug, Copy, Clone)] pub enum Instruction { @@ -55,7 +55,7 @@ pub enum JPTarget { ImmediateWord(u16), } -#[derive(Debug, Copy, Clone)] +#[derive(Copy, Clone)] pub enum Registers { Byte(InstrRegister), Word(RegisterPair), @@ -2076,3 +2076,12 @@ impl std::fmt::Debug for InstrRegisterPair { } } } + +impl std::fmt::Debug for Registers { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match *self { + Registers::Byte(reg) => write!(f, "{:?}", reg), + Registers::Word(pair) => write!(f, "{:?}", pair), + } + } +}