mirror of
https://github.com/jtauber/applepy.git
synced 2024-11-27 07:51:10 +00:00
reimplemented CMP, CPX and CPY based on 2006/2007 code
This commit is contained in:
parent
6fb2d79cda
commit
84bdef67cd
21
applepy.py
21
applepy.py
@ -639,22 +639,19 @@ class CPU:
|
|||||||
# COMPARISON
|
# COMPARISON
|
||||||
|
|
||||||
def CMP(self, operand_address):
|
def CMP(self, operand_address):
|
||||||
value = self.memory.read_byte(operand_address)
|
result = self.accumulator - self.memory.read_byte(operand_address)
|
||||||
self.carry_flag = (self.accumulator >= value)
|
self.carry_flag = (result >= 0)
|
||||||
self.zero_flag = (self.accumulator == value)
|
self.update_nz(result)
|
||||||
self.sign_flag = (self.accumulator < 0x80) # @@@ is this right?
|
|
||||||
|
|
||||||
def CPX(self, operand_address):
|
def CPX(self, operand_address):
|
||||||
value = self.memory.read_byte(operand_address)
|
result = self.x_index - self.memory.read_byte(operand_address)
|
||||||
self.carry_flag = (self.x_index >= value)
|
self.carry_flag = (result >= 0)
|
||||||
self.zero_flag = (self.x_index == value)
|
self.update_nz(result)
|
||||||
self.sign_flag = (self.x_index < 0x80) # TODO: is this right?
|
|
||||||
|
|
||||||
def CPY(self, operand_address):
|
def CPY(self, operand_address):
|
||||||
value = self.memory.read_byte(operand_address)
|
result = self.y_index - self.memory.read_byte(operand_address)
|
||||||
self.carry_flag = (self.y_index >= value)
|
self.carry_flag = (result >= 0)
|
||||||
self.zero_flag = (self.y_index == value)
|
self.update_nz(result)
|
||||||
self.sign_flag = (self.y_index < 0x80) # @@@ is this right?
|
|
||||||
|
|
||||||
# SYSTEM
|
# SYSTEM
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user