genlut.py is really filling out. It generates the LUT for all 68k opcodes (68000 only), and I’m about 70% done. 77 down, 34 to go.
The OPCODES dict defines the first two bytes of each opcode, both static bits and operands. The operand strings act as keys into the PATTERNS struct, which contains all possible values for each operand.
The recursive function gen() is fed an opcode pattern which may contain operand strings as well as static bits.
Decoding is easy. Decoding requires a lot of typing. (I am starting to believe this is true of ever aspect of interpreted emulation…)
For the AEJS decoder, I am creating a look-up table with every possible pattern for each instruction. It was my first idea, but I initially discarded it as “wasteful and inelegant”. Later, I accepted it as “really fast”.
I’m generating a large set of bit patterns that map to 68k opcodes, like so:
Why the Amiga? Given that this is my first emulator, it would have been much easier to go with a 6502 or 8080 instead, but I didn’t grow up with those; I grew up with a 68k powering an Amiga 500.