Jetzt, wo ich einen überblick hab, wie eine CPU überhaupt genau funktioniert und wie man es in Python implementieren könnte, will ich nochmal neu anfangen und systematischer herran gehen...
Dazu habe ich zwei "data scraping" skripte zusammen gehackt:
https://github.com/jedie/DragonPy/commi ... 5f6e75d903
Diese sollen Informationen von diesen Seiten zusammenführen:
http://www.maddes.net/m6809pm/sections.htm#sec4_4
http://www.burgins.com/m6809.html
http://www.maddes.net/m6809pm/appendix_a.htm#appA
Dann soll, als Zwischenschritt, ein "Daten Skript" erzeugt werden, mit allen Informationen. Sieht dann ungefähr so aus:
Code: Alles auswählen
OP_DATA = (
#### 8-Bit Accumulator and Memory Instructions
{
"opcode": 0x0, "instruction": "NEG", "mnemonic": "NEG",
"desc": "Negate accumulator or memory",
"addr_mode": 1, "operant": None,
"cycles": "6", "bytes": "2", "HNZVC": "uaaaa", "category": 0
},
{
"opcode": 0x3, "instruction": "COM", "mnemonic": "COM",
"desc": "Complement accumulator or memory location",
"addr_mode": 1, "operant": None,
"cycles": "6", "bytes": "2", "HNZVC": "-aa01", "category": 0
},
{
"opcode": 0x4, "instruction": "LSR", "mnemonic": "LSR",
"desc": "Logical shift right accumulator or memory location",
"addr_mode": 1, "operant": None,
"cycles": "6", "bytes": "2", "HNZVC": "-0a-s", "category": 0
},
...
Daraus will ich dann ein Python Skript erzeugen, der so ähnlich aussieht:
Code: Alles auswählen
class CPU6809(object):
#### 8-Bit Accumulator and Memory Instructions
# ADC - Add memory to accumulator with carry
@opcode((
0x89, "ADCA", IMMEDIATE, operant=A
0x99, "ADCA", DIRECT, operant=A
0xa9, "ADCA", INDEXED, operant=A
0xb9, "ADCA", EXTENDED, operant=A
0xc9, "ADCB", IMMEDIATE, operant=B
0xd9, "ADCB", DIRECT, operant=B
0xe9, "ADCB", INDEXED, operant=B
0xf9, "ADCB", EXTENDED, operant=B
))
def ADC(self, op, ea=None, operant=None):
raise NotImplementedError("TODO: $%x ADC") % op
# ADD - Add memory to accumulator
@opcode((
0x8b, "ADDA", IMMEDIATE, operant=A
0x9b, "ADDA", DIRECT, operant=A
0xab, "ADDA", INDEXED, operant=A
0xbb, "ADDA", EXTENDED, operant=A
0xcb, "ADDB", IMMEDIATE, operant=B
0xdb, "ADDB", DIRECT, operant=B
0xeb, "ADDB", INDEXED, operant=B
0xfb, "ADDB", EXTENDED, operant=B
))
def ADD(self, op, ea=None, operant=None):
raise NotImplementedError("TODO: $%x ADD") % op
# AND - AND memory with accumulator
@opcode((
0x84, "ANDA", IMMEDIATE, operant=A
0x94, "ANDA", DIRECT, operant=A
0xa4, "ANDA", INDEXED, operant=A
0xb4, "ANDA", EXTENDED, operant=A
0xc4, "ANDB", IMMEDIATE, operant=B
0xd4, "ANDB", DIRECT, operant=B
0xe4, "ANDB", INDEXED, operant=B
0xf4, "ANDB", EXTENDED, operant=B
))
def AND(self, op, ea=None, operant=None):
raise NotImplementedError("TODO: $%x AND") % op
...
Und dann geht es ans implementieren.