Opcode table

Last updated

An opcode table (also called an opcode matrix) is a visual representation of all opcodes in an instruction set. It is arranged such that each axis of the table represents an upper or lower nibble, which combined form the full byte of the opcode. Additional opcode tables can exist for additional instructions created using an opcode prefix.

Contents

Table values

The structure and arrangement of an opcode table appears as follows:

0123456789ABCDEF
0000102030405060708090A0B0C0D0E0F
1101112131415161718191A1B1C1D1E1F
2202122232425262728292A2B2C2D2E2F
3303132333435363738393A3B3C3D3E3F
4404142434445464748494A4B4C4D4E4F
5505152535455565758595A5B5C5D5E5F
6606162636465666768696A6B6C6D6E6F
7707172737475767778797A7B7C7D7E7F
8808182838485868788898A8B8C8D8E8F
9909192939495969798999A9B9C9D9E9F
AA0A1A2A3A4A5A6A7A8A9AAABACADAEAF
BB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF
CC0C1C2C3C4C5C6C7C8C9CACBCCCDCECF
DD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF
EE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF
FF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF

Each cell from 00-FF contains information about the operation such as the equivalent assembly instruction corresponding to the opcode, parameters, and CPU cycle counts.

Example opcode table

This is the opcode table for the MOS Technology 6502 microprocessor from 1975. The 6502 uses 8-bit opcodes. Of the 256 possible opcodes available using an 8-bit pattern, the original 6502 uses only 151 of them, organized into 56 instructions with (possibly) multiple addressing modes. [1] Because not all the 256 opcodes are not used, some opcode spaces are blank and the low nibble columns 3, 7, B, and F are missing from the table.

Opcode matrix for the 6502 instruction set
Addressing modes: A – accumulator, # – immediate, zpg – zero page, abs – absolute, ind – indirect, X – indexed by X register, Y – indexed by Y register, rel – relative
High nibbleLow nibble
01245689ACDE
0BRKORA (ind,X)ORA zpgASL zpgPHPORA #ASL AORA absASL abs
1BPL relORA (ind),YORA zpg,XASL zpg,XCLCORA abs,YORA abs,XASL abs,X
2JSR absAND (ind,X)BIT zpgAND zpgROL zpgPLPAND #ROL ABIT absAND absROL abs
3BMI relAND (ind),YAND zpg,XROL zpg,XSECAND abs,YAND abs,XROL abs,X
4RTIEOR (ind,X)EOR zpgLSR zpgPHAEOR #LSR AJMP absEOR absLSR abs
5BVC relEOR (ind),YEOR zpg,XLSR zpg,XCLIEOR abs,YEOR abs,XLSR abs,X
6RTSADC (ind,X)ADC zpgROR zpgPLAADC #ROR AJMP (ind)ADC absROR abs
7BVS relADC (ind),YADC zpg,XROR zpg,XSEIADC abs,YADC abs,XROR abs,X
8STA (ind,X)STY zpgSTA zpgSTX zpgDEYTXASTY absSTA absSTX abs
9BCC relSTA (ind),YSTY zpg,XSTA zpg,XSTX zpg,YTYASTA abs,YTXSSTA abs,X
ALDY #LDA (ind,X)LDX #LDY zpgLDA zpgLDX zpgTAYLDA #TAXLDY absLDA absLDX abs
BBCS relLDA (ind),YLDY zpg,XLDA zpg,XLDX zpg,YCLVLDA abs,YTSXLDY abs,XLDA abs,XLDX abs,Y
CCPY #CMP (ind,X)CPY zpgCMP zpgDEC zpgINYCMP #DEXCPY absCMP absDEC abs
DBNE relCMP (ind),YCMP zpg,XDEC zpg,XCLDCMP abs,YCMP abs,XDEC abs,X
ECPX #SBC (ind,X)CPX zpgSBC zpgINC zpgINXSBC #NOPCPX absSBC absINC abs
FBEQ relSBC (ind),YSBC zpg,XINC zpg,XSEDSBC abs,YSBC abs,XINC abs,X

References

  1. Parker, Neil. "The 6502/65C02/65C816 Instruction Set Decoded". Neil Parker's Apple II page. Archived from the original on 2019-07-16. Retrieved 2019-07-16.