Created
November 11, 2017 22:26
-
-
Save bit-hack/52d90a2178d734f64c9e90766562799b to your computer and use it in GitHub Desktop.
6502 assembly tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
// operand format | |
enum { | |
OPR_IMM = 0, | |
OPR_ZP, | |
OPR_ZPX, | |
OPR_ZPY, | |
OPR_ABS, | |
OPR_ABSX, | |
OPR_ABSY, | |
OPR_IND, | |
OPR_INDX, | |
OPR_INDY, | |
OPR_SNGL, | |
OPR_BRA | |
} | |
struct asm_entry_t { | |
char mnemonic[4]; | |
uint8_t opcodes[12]; | |
}; | |
static const asm_entry_t asm_table[] = { | |
#define ____ 0xff | |
/* 2 2 2 2 3 3 3 3 2 2 1 2 */ | |
/* NAME, IMM, ZP, ZPX, ZPY, ABS, ABSX, ABSY, IND, INDX, INDY, SNGL, BRA */ | |
{"ADC", 0x69, 0x65, 0x75, ____, 0x6d, 0x7d, 0x79, ____, 0x61, 0x71, ____, ____}, | |
{"AND", 0x29, 0x25, 0x35, ____, 0x2d, 0x3d, 0x39, ____, 0x21, 0x31, ____, ____}, | |
{"ASL", ____, 0x06, 0x16, ____, 0x0e, 0x1e, ____, ____, ____, ____, 0x0a, ____}, | |
{"BCC", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x90}, | |
{"BCS", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xb0}, | |
{"BEQ", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xf0}, | |
{"BIT", ____, 0x24, ____, ____, 0x2c, ____, ____, ____, ____, ____, ____, ____}, | |
{"BMI", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x30}, | |
{"BNE", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xd0}, | |
{"BPL", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x10}, | |
{"BRK", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x00, ____}, | |
{"BVC", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x50}, | |
{"BVS", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x70}, | |
{"CLC", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x18, ____}, | |
{"CLD", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xd8, ____}, | |
{"CLI", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x58, ____}, | |
{"CLV", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xb8, ____}, | |
{"CMP", 0xc9, 0xc5, 0xd5, ____, 0xcd, 0xdd, 0xd9, ____, 0xc1, 0xd1, ____, ____}, | |
{"CPX", 0xe0, 0xe4, ____, ____, 0xec, ____, ____, ____, ____, ____, ____, ____}, | |
{"CPY", 0xc0, 0xc4, ____, ____, 0xcc, ____, ____, ____, ____, ____, ____, ____}, | |
{"DEC", ____, 0xc6, 0xd6, ____, 0xce, 0xde, ____, ____, ____, ____, ____, ____}, | |
{"DEX", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xca, ____}, | |
{"DEY", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x88, ____}, | |
{"EOR", 0x49, 0x45, 0x55, ____, 0x4d, 0x5d, 0x59, ____, 0x41, 0x51, ____, ____}, | |
{"INC", ____, 0xe6, 0xf6, ____, 0xee, 0xfe, ____, ____, ____, ____, ____, ____}, | |
{"INX", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xe8, ____}, | |
{"INY", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xc8, ____}, | |
{"JMP", ____, ____, ____, ____, 0x4c, ____, ____, 0x6c, ____, ____, ____, ____}, | |
{"JSR", ____, ____, ____, ____, 0x20, ____, ____, ____, ____, ____, ____, ____}, | |
{"LDA", 0xa9, 0xa5, 0xb5, ____, 0xad, 0xbd, 0xb9, ____, 0xa1, 0xb1, ____, ____}, | |
{"LDX", 0xa2, 0xa6, ____, 0xb6, 0xae, ____, 0xbe, ____, ____, ____, ____, ____}, | |
{"LDY", 0xa0, 0xa4, 0xb4, ____, 0xac, 0xbc, ____, ____, ____, ____, ____, ____}, | |
{"LSR", ____, 0x46, 0x56, ____, 0x4e, 0x5e, ____, ____, ____, ____, 0x4a, ____}, | |
{"NOP", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xea, ____}, | |
{"ORA", 0x09, 0x05, 0x15, ____, 0x0d, 0x1d, 0x19, ____, 0x01, 0x11, ____, ____}, | |
{"PHA", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x48, ____}, | |
{"PHP", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x08, ____}, | |
{"PLA", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x68, ____}, | |
{"PLP", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x28, ____}, | |
{"ROL", ____, 0x26, 0x36, ____, 0x2e, 0x3e, ____, ____, ____, ____, 0x2a, ____}, | |
{"ROR", ____, 0x66, 0x76, ____, 0x6e, 0x7e, ____, ____, ____, ____, 0x6a, ____}, | |
{"RTI", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x40, ____}, | |
{"RTS", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x60, ____}, | |
{"SBC", 0xe9, 0xe5, 0xf5, ____, 0xed, 0xfd, 0xf9, ____, 0xe1, 0xf1, ____, ____}, | |
{"SEC", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x38, ____}, | |
{"SED", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xf8, ____}, | |
{"SEI", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x78, ____}, | |
{"STA", ____, 0x85, 0x95, ____, 0x8d, 0x9d, 0x99, ____, 0x81, 0x91, ____, ____}, | |
{"STX", ____, 0x86, ____, 0x96, 0x8e, ____, ____, ____, ____, ____, ____, ____}, | |
{"STY", ____, 0x84, 0x94, ____, 0x8c, ____, ____, ____, ____, ____, ____, ____}, | |
{"TAX", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xaa, ____}, | |
{"TAY", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xa8, ____}, | |
{"TSX", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0xba, ____}, | |
{"TXA", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x8a, ____}, | |
{"TXS", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x9a, ____}, | |
{"TYA", ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, 0x98, ____}, | |
{"WDM", 0x42, 0x42, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____}, | |
#undef ____ | |
}; | |
const uint8_t asm_index[] = { | |
#define __ 0xff | |
// a b c d e f g h i j k l m n o p q r s | |
0, 3, 13, 20, 23, __, __, __, 24, 27, __, 29, __, 33, 34, 35, __, 39, 43, | |
// t u v w x y z | |
50, __, __, 56, __, __, __ | |
#undef __ | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment