mirror of
https://github.com/mnaberez/py65.git
synced 2024-11-07 21:05:41 +00:00
Implemented all STZ for 65C02. Trying out new idea for instruction definitions.
Signed-off-by: Mike Naberezny <mike@naberezny.com>
This commit is contained in:
parent
f1d553a485
commit
aa8ef0ebca
@ -1,26 +1,49 @@
|
||||
#from py65.utils.conversions import convert_to_bin, convert_to_bcd
|
||||
import mpu6502
|
||||
|
||||
def make_instruction_decorator(instruct, cycletime, extracycles):
|
||||
def instruction(opcode, opcycles, opextracycles=0):
|
||||
def decorate(f):
|
||||
instruct[opcode] = f
|
||||
cycletime[opcode] = opcycles
|
||||
extracycles[opcode] = opextracycles
|
||||
return f # Return the original function
|
||||
return decorate
|
||||
return instruction
|
||||
|
||||
|
||||
class MPU(mpu6502.MPU):
|
||||
def __init__(self, memory=None, pc=0x0000, debug=False):
|
||||
mpu6502.MPU.__init__(self, memory=memory, pc=pc, debug=debug)
|
||||
self.name = '65C02'
|
||||
|
||||
instruct = mpu6502.MPU.instruct[:]
|
||||
cycletime = mpu6502.MPU.cycletime[:]
|
||||
extracycles = mpu6502.MPU.extracycles[:]
|
||||
|
||||
instruction = \
|
||||
make_instruction_decorator(instruct, cycletime, extracycles)
|
||||
|
||||
def opSTZ(self, x):
|
||||
self.memory[x()] = 0x00
|
||||
|
||||
@instruction(0x64, 3)
|
||||
def i64(self):
|
||||
self.opSTZ(self.ZeroPageAddr)
|
||||
self.pc += 1
|
||||
|
||||
# code pages
|
||||
@instruction(0x74, 4)
|
||||
def i74(self):
|
||||
self.opSTZ(self.ZeroPageXAddr)
|
||||
self.pc += 1
|
||||
|
||||
instruct = mpu6502.MPU.instruct[:]
|
||||
instruct[0x64] = i64
|
||||
@instruction(0x9c, 4)
|
||||
def i9c(self):
|
||||
self.opSTZ(self.AbsoluteAddr)
|
||||
self.pc += 2
|
||||
|
||||
cycletime = mpu6502.MPU.cycletime[:]
|
||||
cycletime[0x64] = 3
|
||||
|
||||
extracycles = mpu6502.MPU.extracycles[:]
|
||||
extracycles[0x64] = 0
|
||||
@instruction(0x9e, 5)
|
||||
def i9e(self):
|
||||
self.opSTZ(self.AbsoluteXAddr)
|
||||
self.pc+=2
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user