I am writing an interpreted 68k emulator as a personal / educational project. Now I am trying to develop a simple, general decoding mechanism.
As I understand it, the first two bytes of each command are enough to uniquely identify the operation (with two rare exceptions) and the number of words that need to be read, if any.
Here is what I would like to do at the decoding stage:
1. read two bytes
2. determine which instruction it is
3. extract the operands
4. pass the opcode and the operands on to the execute phase
I can't just pass the first two bytes to the lookup table, as I could, using the first few bits in the RISC arch, because the operands are "on the way." How can I complete a piece 2in general?
All in all, my question is: How to remove operand variability from the decoding process?
More background:
The following is a partial table from section 8.2 of the Programmer's Reference Guide:
Table 8.2. Operation Code Map
Bits 15-12 Operation
0000 Bit Manipulation/MOVEP/Immediate
0001 Move Byte
...
1110 Shift/Rotate/Bit Field
1111 Coprocessor Interface...
This was of great importance to me, but then I look at the bit patterns for each instruction and notice that there is not a single instruction where bits 15-12 are 0001, 0010 or 0011. There should be some big part of the image that I don’t enough.
This Z80 Opcodes decoding site explicitly explains decoding, which I did not find in the 68k programmer's reference guide or googling.
source
share