mirror of
https://github.com/lloeki/python-dcpu_16.git
synced 2025-12-06 09:54:39 +01:00
naive nib dispatch. should not be so complex.
This commit is contained in:
parent
060ed1662f
commit
3f559dcf32
1 changed files with 14 additions and 6 deletions
20
dcpu_16.py
20
dcpu_16.py
|
|
@ -384,19 +384,27 @@ class CPU(object):
|
|||
def step(c):
|
||||
"""start handling [PC]"""
|
||||
word = c.m[c.pc]
|
||||
opcode = word & 0xF
|
||||
c.pc = (c.pc + 1) & wmask
|
||||
if (word & 0xF) > 0:
|
||||
opcode = (word & 0xF,)
|
||||
a = c._pointer(word >> 4 & 0x3F)
|
||||
b = c._pointer(word >> 10 & 0x3F)
|
||||
args = (a, b)
|
||||
elif (word >> 4 & 0x3F) > 0:
|
||||
opcode = (0x0, word >> 4 & 0x3F)
|
||||
a = c._pointer(word >> 10 & 0x3F)
|
||||
args = (a, )
|
||||
else:
|
||||
raise Exception('Invalid opcode %s at PC=%04X' % (["%02X"%x for x in opcode], c.pc))
|
||||
try:
|
||||
op = opcode_map[(opcode,)]
|
||||
op = opcode_map[opcode]
|
||||
if c.debug: log(op.__name__)
|
||||
except KeyError:
|
||||
raise Exception('Invalid opcode %01X at PC=%04X' % (opcode, c.pc))
|
||||
a = c._pointer(word >> 4 & 0x3F)
|
||||
b = c._pointer(word >> 10 & 0x3F)
|
||||
raise Exception('Invalid opcode %s at PC=%04X' % (["%02X"%x for x in opcode], c.pc))
|
||||
if c.skip:
|
||||
c.skip = False
|
||||
else:
|
||||
op(c, a, b)
|
||||
op(c, *args)
|
||||
if c.debug: log(c.dump_r())
|
||||
|
||||
def dump_r(c):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue