aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-08-27 07:27:58 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-09-06 15:47:50 +0200
commitf79b01fa30f894f2b3ad22181c25ff555479018a (patch)
treee494fb06d2b35dcba1c986494e1a9fff23fae104
parentc113a1c506e46f6bc5a4c95c7a786a72de081e34 (diff)
downloadtools.nes-f79b01fa30f894f2b3ad22181c25ff555479018a.tar.gz
tools.nes-f79b01fa30f894f2b3ad22181c25ff555479018a.zip
Implement the bvc and bvs instructions
They were the last ones marked with the todo!() macro. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
-rw-r--r--lib/vnf/src/lib.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/vnf/src/lib.rs b/lib/vnf/src/lib.rs
index e2d066b..ab8973b 100644
--- a/lib/vnf/src/lib.rs
+++ b/lib/vnf/src/lib.rs
@@ -771,10 +771,6 @@ impl Machine {
self.status_register.overflow = false;
match self.current_instruction.identifier {
- // TODO
- InstructionIdentifier::Bvc => todo!(),
- InstructionIdentifier::Bvs => todo!(),
-
// Flag instructions.
InstructionIdentifier::Sec => self.status_register.carry = true,
InstructionIdentifier::Clc => self.status_register.carry = false,
@@ -1042,6 +1038,17 @@ impl Machine {
self.branch();
}
}
+ InstructionIdentifier::Bvc => {
+ if !self.status_register.overflow {
+ self.branch();
+ }
+ }
+ InstructionIdentifier::Bvs => {
+ if self.status_register.overflow {
+ self.branch();
+ }
+ }
+
InstructionIdentifier::Rts => {
// If the stack is empty but we were just running a function,
// then assume that the machine is done.