1
0
mirror of https://github.com/mnaberez/py65.git synced 2025-01-19 23:31:03 +00:00

Applied patch from Ed Spittles to fix Z and C flags for SBC. Closes #15.

This commit is contained in:
Mike Naberezny 2009-09-03 22:46:37 -07:00
parent 7a54ad06f3
commit 460cc4e48e
2 changed files with 10 additions and 5 deletions

View File

@ -29,6 +29,11 @@ Next Release
Overflow (V) flag. This fixes a failure in Rob Finch's test suite. Overflow (V) flag. This fixes a failure in Rob Finch's test suite.
Closes #6. Closes #6.
- Applied patch from Ed Spittles so that SBC now properly sets the
Carry (C) and Zero (Z) flags. This fixes failures caught by Ed's
own tests (see http://forum.6502.org/viewtopic.php?p=8854#8854).
Closes #15.
- A new "save" command has been added to the monitor that will save - A new "save" command has been added to the monitor that will save
a range of memory to a binary file. a range of memory to a binary file.

View File

@ -382,17 +382,17 @@ class MPU:
else: else:
borrow = 1 borrow = 1
result = self.a - data - borrow result = self.a + (~data & 0xFF) + (self.p & self.CARRY)
self.p &= ~(self.CARRY + self.ZERO + self.OVERFLOW + self.NEGATIVE) self.p &= ~(self.CARRY + self.ZERO + self.OVERFLOW + self.NEGATIVE)
if ( (self.a ^ data) & (self.a ^ result) ) & 0x80: if ( (self.a ^ data) & (self.a ^ result) ) & 0x80:
self.p |= self.OVERFLOW self.p |= self.OVERFLOW
data = result data = result & 0xFF
if data == 0: if data == 0:
self.p |= self.ZERO + self.CARRY self.p |= self.ZERO
elif data > 0: if result & 0x100:
self.p |= self.CARRY self.p |= self.CARRY
self.p |= data & self.NEGATIVE self.p |= data & self.NEGATIVE
self.a = data & 0xFF self.a = data
def opDECR(self, x): def opDECR(self, x):
if x is None: if x is None: