mirror of
https://github.com/mnaberez/py65.git
synced 2025-08-09 04:24:59 +00:00
First 65c02 instruction
Signed-off-by: Mike Naberezny <mike@naberezny.com>
This commit is contained in:
committed by
Mike Naberezny
parent
304422978d
commit
f1d553a485
@@ -16,9 +16,10 @@ class MPU:
|
|||||||
ZERO = 2
|
ZERO = 2
|
||||||
CARRY = 1
|
CARRY = 1
|
||||||
|
|
||||||
def __init__(self, memory=None, pc=0x0000):
|
def __init__(self, memory=None, pc=0x0000, debug=False):
|
||||||
# config
|
# config
|
||||||
self.debug = False
|
self.debug = debug
|
||||||
|
self.name = '6502'
|
||||||
|
|
||||||
# vm status
|
# vm status
|
||||||
self.breakFlag = False
|
self.breakFlag = False
|
||||||
@@ -36,8 +37,8 @@ class MPU:
|
|||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
out = '<6502: A=%02x, X=%02x, Y=%02x, Flags=%02x, SP=%02x, PC=%04x>'
|
out = '<%s: A=%02x, X=%02x, Y=%02x, Flags=%02x, SP=%02x, PC=%04x>'
|
||||||
return out % (self.a, self.x, self.y,
|
return out % (self.name, self.a, self.x, self.y,
|
||||||
self.flags, self.sp, self.pc)
|
self.flags, self.sp, self.pc)
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
|
@@ -1,83 +1,26 @@
|
|||||||
#from py65.utils.conversions import convert_to_bin, convert_to_bcd
|
#from py65.utils.conversions import convert_to_bin, convert_to_bcd
|
||||||
from mpu6502 import MPU as MPU6502
|
import mpu6502
|
||||||
|
|
||||||
class MPU(MPU6502):
|
class MPU(mpu6502.MPU):
|
||||||
def __init__(self, memory=None, pc=0x0000):
|
def __init__(self, memory=None, pc=0x0000, debug=False):
|
||||||
MPU6502.__init__(self, memory=memory, pc=pc)
|
mpu6502.MPU.__init__(self, memory=memory, pc=pc, debug=debug)
|
||||||
|
self.name = '65C02'
|
||||||
|
|
||||||
|
def opSTZ(self, x):
|
||||||
|
self.memory[x()] = 0x00
|
||||||
|
|
||||||
|
def i64(self):
|
||||||
|
self.opSTZ(self.ZeroPageAddr)
|
||||||
|
self.pc += 1
|
||||||
|
|
||||||
# code pages
|
# code pages
|
||||||
|
|
||||||
"""
|
instruct = mpu6502.MPU.instruct[:]
|
||||||
instruct = [
|
instruct[0x64] = i64
|
||||||
i00, i01, ini, ini, ini, i05, i06, ini,
|
|
||||||
i08, i09, i0a, ini, ini, i0d, i0e, ini,
|
|
||||||
i10, i11, ini, ini, ini, i15, i16, ini,
|
|
||||||
i18, i19, ini, ini, ini, i1d, i1e, ini,
|
|
||||||
i20, i21, ini, ini, i24, i25, i26, ini,
|
|
||||||
i28, i29, i2a, ini, i2c, i2d, i2e, ini,
|
|
||||||
i30, i31, ini, ini, ini, i35, i36, ini,
|
|
||||||
i38, i39, ini, ini, ini, i3d, i3e, ini,
|
|
||||||
i40, i41, ini, ini, ini, i45, i46, ini,
|
|
||||||
i48, i49, i4a, ini, i4c, i4d, i4e, ini,
|
|
||||||
i50, i51, ini, ini, ini, i55, i56, ini,
|
|
||||||
i58, i59, ini, ini, ini, i5d, i5e, ini,
|
|
||||||
i60, i61, ini, ini, ini, i65, i66, ini,
|
|
||||||
i68, i69, i6a, ini, i6c, i6d, i6e, ini,
|
|
||||||
i70, i71, ini, ini, ini, i75, i76, ini,
|
|
||||||
i78, i79, ini, ini, ini, i7d, i7e, ini,
|
|
||||||
ini, i81, ini, ini, i84, i85, i86, ini,
|
|
||||||
i88, ini, i8a, ini, i8c, i8d, i8e, ini,
|
|
||||||
i90, i91, ini, ini, i94, i95, i96, ini,
|
|
||||||
i98, i99, i9a, ini, ini, i9d, ini, ini,
|
|
||||||
ia0, ia1, ia2, ini, ia4, ia5, ia6, ini,
|
|
||||||
ia8, ia9, iaa, ini, iac, iad, iae, ini,
|
|
||||||
ib0, ib1, ini, ini, ib4, ib5, ib6, ini,
|
|
||||||
ib8, ib9, iba, ini, ibc, ibd, ibe, ini,
|
|
||||||
ic0, ic1, ini, ini, ic4, ic5, ic6, ini,
|
|
||||||
ic8, ic9, ica, ini, icc, icd, ice, ini,
|
|
||||||
id0, id1, ini, ini, ini, id5, id6, ini,
|
|
||||||
id8, id9, ini, ini, ini, idd, ide, ini,
|
|
||||||
ie0, ie1, ini, ini, ie4, ie5, ie6, ini,
|
|
||||||
ie8, ie9, iea, ini, iec, ied, iee, ini,
|
|
||||||
if0, if1, ini, ini, ini, if5, if6, ini,
|
|
||||||
if8, if9, ini, ini, ini, ifd, ife, ini
|
|
||||||
]
|
|
||||||
|
|
||||||
cycletime = [
|
cycletime = mpu6502.MPU.cycletime[:]
|
||||||
7, 6, 0, 0, 0, 3, 5, 0, 3, 2, 2, 0, 0, 4, 6, 0, # 00
|
cycletime[0x64] = 3
|
||||||
2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0, # 10
|
|
||||||
6, 6, 0, 0, 3, 3, 5, 0, 4, 2, 2, 0, 4, 4, 6, 0, # 20
|
extracycles = mpu6502.MPU.extracycles[:]
|
||||||
2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0, # 30
|
extracycles[0x64] = 0
|
||||||
6, 6, 0, 0, 0, 3, 5, 0, 3, 2, 2, 0, 3, 4, 6, 0, # 40
|
|
||||||
2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0, # 50
|
|
||||||
6, 6, 0, 0, 0, 3, 5, 0, 4, 2, 2, 0, 5, 4, 6, 0, # 60
|
|
||||||
2, 5, 0, 0, 0, 4, 6, 0, 2, 4, 0, 0, 0, 4, 7, 0, # 70
|
|
||||||
0, 6, 0, 0, 3, 3, 3, 0, 2, 0, 2, 0, 4, 4, 4, 0, # 80
|
|
||||||
2, 6, 0, 0, 4, 4, 4, 0, 2, 5, 2, 0, 0, 5, 0, 0, # 90
|
|
||||||
2, 6, 2, 0, 3, 3, 3, 0, 2, 2, 2, 0, 4, 4, 4, 0, # A0
|
|
||||||
2, 5, 0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
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # C0
|
|
||||||
2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, # D0
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # E0
|
|
||||||
2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0 # F0
|
|
||||||
]
|
|
||||||
"""
|
|
||||||
|
@@ -2,7 +2,8 @@ import unittest
|
|||||||
import sys
|
import sys
|
||||||
from py65.mpu6502 import MPU
|
from py65.mpu6502 import MPU
|
||||||
|
|
||||||
class MPUTests(unittest.TestCase):
|
def make_common_tests(MPU):
|
||||||
|
class MPUTests(unittest.TestCase):
|
||||||
|
|
||||||
# ADC Absolute
|
# ADC Absolute
|
||||||
|
|
||||||
@@ -4575,9 +4576,23 @@ class MPUTests(unittest.TestCase):
|
|||||||
self.assertEquals(0x00, mpu.y)
|
self.assertEquals(0x00, mpu.y)
|
||||||
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
|
self.assertEquals(mpu.ZERO, mpu.flags & mpu.ZERO)
|
||||||
self.assertEquals(0x0001, mpu.pc)
|
self.assertEquals(0x0001, mpu.pc)
|
||||||
|
return MPUTests
|
||||||
|
|
||||||
|
|
||||||
|
MPUTests = make_common_tests(MPU)
|
||||||
|
|
||||||
|
class MPU6502SpecificTests(unittest.TestCase):
|
||||||
|
def test_repr(self):
|
||||||
|
mpu = MPU()
|
||||||
|
self.assertEquals('<6502: A=00, X=00, Y=00, Flags=20, SP=ff, PC=0000>',
|
||||||
|
repr(mpu))
|
||||||
|
|
||||||
|
def test_stz_not_supported(self):
|
||||||
|
mpu = MPU(debug=True)
|
||||||
|
mpu.memory[0x0000] = 0x64 #=> stz (on 65c02)
|
||||||
|
self.assertRaises(NotImplementedError, mpu.step)
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.findTestCases(sys.modules[__name__])
|
return unittest.findTestCases(sys.modules[__name__])
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user