From 440f3bdb10a61fc421632ac8dd342b04137517af Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 16 Oct 2023 15:47:06 -0400 Subject: [PATCH] Further improve error reporting. --- InstructionSets/x86/Status.hpp | 19 +++++++++++++++++++ OSBindings/Mac/Clock SignalTests/8088Tests.mm | 6 ++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/InstructionSets/x86/Status.hpp b/InstructionSets/x86/Status.hpp index 71efb2f8c..a79146200 100644 --- a/InstructionSets/x86/Status.hpp +++ b/InstructionSets/x86/Status.hpp @@ -184,6 +184,25 @@ class Status { (not_parity_bit() ? 0 : ConditionCode::Parity); } + std::string to_string() const { + std::string result; + + if(overflow) result += "O"; else result += "-"; + if(direction) result += "D"; else result += "-"; + if(interrupt) result += "I"; else result += "-"; + if(trap) result += "T"; else result += "-"; + if(sign) result += "S"; else result += "-"; + if(!zero) result += "S"; else result += "-"; + result += "-"; + if(auxiliary_carry) result += "A"; else result += "-"; + result += "-"; + if(!not_parity_bit()) result += "P"; else result += "-"; + result += "-"; + if(carry) result += "C"; else result += "-"; + + return result; + } + bool operator ==(const Status &rhs) const { return get() == rhs.get(); } diff --git a/OSBindings/Mac/Clock SignalTests/8088Tests.mm b/OSBindings/Mac/Clock SignalTests/8088Tests.mm index 30e21bdee..0f9db80f8 100644 --- a/OSBindings/Mac/Clock SignalTests/8088Tests.mm +++ b/OSBindings/Mac/Clock SignalTests/8088Tests.mm @@ -702,9 +702,11 @@ struct FailedExecution { NSMutableArray *reasons = [[NSMutableArray alloc] init]; if(!statusEqual) { + Status difference; + difference.set((intended_status.get() ^ execution_support.status.get()) & flags_mask); [reasons addObject: - [NSString stringWithFormat:@"status differs by %04x", - (intended_status.get() ^ execution_support.status.get()) & flags_mask]]; + [NSString stringWithFormat:@"status differs; errors in %s", + difference.to_string().c_str()]]; } if(!registersEqual) { [reasons addObject:@"registers don't match"];