From 84bdef67cdaebe6a68c6da2c048b05393b0c302a Mon Sep 17 00:00:00 2001 From: James Tauber Date: Sat, 6 Aug 2011 22:39:11 -0400 Subject: [PATCH] reimplemented CMP, CPX and CPY based on 2006/2007 code --- applepy.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/applepy.py b/applepy.py index 3843d4f..0d7d0c1 100644 --- a/applepy.py +++ b/applepy.py @@ -639,22 +639,19 @@ class CPU: # COMPARISON def CMP(self, operand_address): - value = self.memory.read_byte(operand_address) - self.carry_flag = (self.accumulator >= value) - self.zero_flag = (self.accumulator == value) - self.sign_flag = (self.accumulator < 0x80) # @@@ is this right? + result = self.accumulator - self.memory.read_byte(operand_address) + self.carry_flag = (result >= 0) + self.update_nz(result) def CPX(self, operand_address): - value = self.memory.read_byte(operand_address) - self.carry_flag = (self.x_index >= value) - self.zero_flag = (self.x_index == value) - self.sign_flag = (self.x_index < 0x80) # TODO: is this right? + result = self.x_index - self.memory.read_byte(operand_address) + self.carry_flag = (result >= 0) + self.update_nz(result) def CPY(self, operand_address): - value = self.memory.read_byte(operand_address) - self.carry_flag = (self.y_index >= value) - self.zero_flag = (self.y_index == value) - self.sign_flag = (self.y_index < 0x80) # @@@ is this right? + result = self.y_index - self.memory.read_byte(operand_address) + self.carry_flag = (result >= 0) + self.update_nz(result) # SYSTEM