3 ms·
I'd categorize things a bit differently. The chips all have an octal encoding, although the 6502 groups the bits from the left (so the encoding is even less use
by kens 6y ago
I'd categorize things a bit differently. The chips all have an octal encoding, although the 6502 groups the bits from the left (so the encoding is even less useful). (The strange thing is these chips are always documented in hexadecimal, which obscures most of the structure.) The Z-80, like the 6502, uses a PLA, while the 8068 uses a weird hybrid PLA-ROM for microcode.
All the chips have a lot of internal structure to their opcodes, since certain bit fields specify the ALU operation, register, etc. Overall, I'd say the 6502 is the most structured, both because its instruction set is simple and because they didn't have backwards-compatibility to worry about. The 8086 has a lot of special-case instructions wedged into random spots, as well as a lot of inconsistency. For instance, sometimes bits 5-7 specify the register, sometimes bits 2-4, sometimes bits 3-4. And then there are the multi-byte "group" instructions tossed into the mix.
- bonzini 6y agoThe x86 encoding is fairly simple as there are only four kind of opcodes: * one byte with implicit operands, for example LOOP or RET or ADD AX,imm * one byte shortcut encoding with registers in bits 0-2 of the only opcode byte, these are 16-bit instruction only: INC/DEC, PUSH/POP, XCHG AX,rr (these instructions are also available as 2-byte encodings) * two byte with one register and one register/memory operand, both encoded in the second byte (bits 3-5 and 0-2/6-7, with bit 0 of the first byte determining the size and bit 1 of the first byte determining if the source is the register or the register/memory operand) * two byte with a single register/memory operand, in which case bits 3-5 of the second byte are part of the opcode Prefixes and immediate operands complicate things a bit but that's it. It's refreshingly simple compared to the 386 and later. An interesting tidbit is that registers are ordered AX/CX/DX/BX in the instruction set encoding because their function roughly matches AF/BC/DE/HL in the 8080 (BX comes last because like HL it can be used to address memory, even though the encoding of memory operands is completely different on the 8086)