From b90cd9bd45322c103433e97e775e88991930313c Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Sat, 7 Sep 2024 18:29:52 +1200 Subject: Implement DB4 instruction for unit tests When the DB4 instruction is evaluated, a single '.' character will be printed to stdout if the return stack is empty and the working stack contains a single 0xff byte, otherwise a single 'X' character will be printed to stdout. This is to facilitate unit testing the instruction set with a Bedrock program, from within the emulator. --- src/emulator.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/emulator.rs') diff --git a/src/emulator.rs b/src/emulator.rs index 4909a27..d983378 100644 --- a/src/emulator.rs +++ b/src/emulator.rs @@ -93,6 +93,15 @@ impl BedrockEmulator { DebugVariant::DB3 => { // Only resets the debug timer } + DebugVariant::DB4 => { + if self.vm.wst.sp == 1 + && self.vm.rst.sp == 0 + && self.vm.wst.mem[0] == 0xff { + print!(".") + } else { + print!("X") + } + } _ => (), } self.cycles_elapsed = self.vm.cycles; -- cgit v1.2.3-70-g09d2