; Opcode lookup table for 6502asm
; v0.02 2008/06/11
;
; Supports NMOS 6502 *and* CMOS 65C02 addressing modes.
;
; Information sources:
;   CPU         Source
;   ----------  -------------------------------------------
;   NMOS 6502   Rockwell R6502 datasheet
;   CMOS 65C02  Western Digital W65C02S (02/2004) datasheet
;
;
; CPU types:
;   0   =  Undefined
;   1   =  NMOS 6502
;   2   =  CMOS 65C02
;   3-8 =  reserved
;   9   =  AmlieEm debug extensions
;
; All "Zpi" addressing mode instructions are taken to be 65C02 specific.
; There is a bodge for identifying the follow as CMOS specific:
;   INC (abs), DEC (abs), BIT (zpx / abs,x), JMP (abs, x)
;
;
; The assembler DOES NOT permit the use of 'undocumented' NMOS
; instructions. If these are required, they must be inserted as
; bytes, like DCB <whatever>...
;
;
; The table MUST be formatted like shown. There is no tolerance for errors.
; The layout is:
;   <opcode>,<cputype>,acc,imm,abs,zpa,zpx,zpy,abx,aby,imp,rel,inx,iny,abi,emu
;
; NOTE that 6502asm makes an assumption regarding "emulator-specific"
; instructions:
;   Anything starting with 'e' that is 'implied' addressing and
;   where the second letter is NOT 'o'.
; Thus "EOR" and "EOL" and "EOX" (etc) will be taken as real instructions
; while "ERA" and "EFG" (etc) will be takn as emulator instructions.
; Modify COMMAND.C to alter this behaviour.
;

;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
adc,1,--,69,6D,65,75,--,7D,79,--,--,61,71,--,--,72
and,1,--,29,2D,25,35,--,3D,39,--,--,21,31,--,--,32
asl,1,0A,--,0E,06,16,--,1E,--,--,--,--,--,--,--,--
bcc,1,--,--,--,--,--,--,--,--,--,90,--,--,--,--,--
bcs,1,--,--,--,--,--,--,--,--,--,B0,--,--,--,--,--
beq,1,--,--,--,--,--,--,--,--,--,F0,--,--,--,--,--
bit,1,--,--,2C,24,34,--,3C,--,--,--,--,--,--,--,--
bmi,1,--,--,--,--,--,--,--,--,--,30,--,--,--,--,--
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
bne,1,--,--,--,--,--,--,--,--,--,D0,--,--,--,--,--
bpl,1,--,--,--,--,--,--,--,--,--,10,--,--,--,--,--
brk,1,--,--,--,--,--,--,--,--,00,--,--,--,--,--,--
bvc,1,--,--,--,--,--,--,--,--,--,50,--,--,--,--,--
bvs,1,--,--,--,--,--,--,--,--,--,70,--,--,--,--,--
clc,1,--,--,--,--,--,--,--,--,18,--,--,--,--,--,--
cld,1,--,--,--,--,--,--,--,--,D8,--,--,--,--,--,--
cli,1,--,--,--,--,--,--,--,--,58,--,--,--,--,--,--
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
clv,1,--,--,--,--,--,--,--,--,B8,--,--,--,--,--,--
cmp,1,--,C9,CD,C5,D5,--,DD,D9,--,--,C1,D1,--,--,D2
cpx,1,--,E0,EC,E4,--,--,--,--,--,--,--,--,--,--,--
cpy,1,--,C0,CC,C4,--,--,--,--,--,--,--,--,--,--,--
dec,1,3A,--,CE,C6,D6,--,DE,--,--,--,--,--,--,--,--
dex,1,--,--,--,--,--,--,--,--,CA,--,--,--,--,--,--
dey,1,--,--,--,--,--,--,--,--,88,--,--,--,--,--,--
eor,1,--,49,4D,45,55,--,5D,59,--,--,41,51,--,--,52
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
inc,1,1A,--,EE,E6,F6,--,FE,--,--,--,--,--,--,--,--
inx,1,--,--,--,--,--,--,--,--,E8,--,--,--,--,--,--
iny,1,--,--,--,--,--,--,--,--,C8,--,--,--,--,--,--
jmp,1,--,--,4C,--,--,--,7C,--,--,--,--,--,6C,--,--
jsr,1,--,--,20,--,--,--,--,--,--,--,--,--,--,--,--
lda,1,--,A9,AD,A5,B5,--,BD,B9,--,--,A1,B1,--,--,B2
ldx,1,--,A2,AE,A6,--,B6,--,BE,--,--,--,--,--,--,--
ldy,1,--,A0,AC,A4,B4,--,BC,--,--,--,--,--,--,--,--
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
lsr,1,4A,--,4E,46,56,--,5E,--,--,--,--,--,--,--,--
nop,1,--,--,--,--,--,--,--,--,EA,--,--,--,--,--,--
ora,1,--,09,0D,05,15,--,1D,19,--,--,01,11,--,--,12
pha,1,--,--,--,--,--,--,--,--,48,--,--,--,--,--,--
php,1,--,--,--,--,--,--,--,--,08,--,--,--,--,--,--
pla,1,--,--,--,--,--,--,--,--,68,--,--,--,--,--,--
plp,1,--,--,--,--,--,--,--,--,28,--,--,--,--,--,--
rol,1,2A,--,2E,26,36,--,3E,--,--,--,--,--,--,--,--
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
ror,1,6A,--,6E,66,76,--,7E,--,--,--,--,--,--,--,--
rti,1,--,--,--,--,--,--,--,--,40,--,--,--,--,--,--
rts,1,--,--,--,--,--,--,--,--,60,--,--,--,--,--,--
sbc,1,--,E9,ED,E5,F5,--,FD,F9,--,--,E1,F1,--,--,F2
sec,1,--,--,--,--,--,--,--,--,38,--,--,--,--,--,--
sed,1,--,--,--,--,--,--,--,--,F8,--,--,--,--,--,--
sei,1,--,--,--,--,--,--,--,--,78,--,--,--,--,--,--
sta,1,--,--,8D,85,95,--,9D,99,--,--,81,91,--,--,92
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
stx,1,--,--,8E,86,--,96,--,--,--,--,--,--,--,--,--
sty,1,--,--,8C,84,94,--,--,--,--,--,--,--,--,--,--
tax,1,--,--,--,--,--,--,--,--,AA,--,--,--,--,--,--
tay,1,--,--,--,--,--,--,--,--,A8,--,--,--,--,--,--
tsx,1,--,--,--,--,--,--,--,--,BA,--,--,--,--,--,--
txa,1,--,--,--,--,--,--,--,--,8A,--,--,--,--,--,--
txs,1,--,--,--,--,--,--,--,--,9A,--,--,--,--,--,--
tya,1,--,--,--,--,--,--,--,--,98,--,--,--,--,--,--
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi

; The following are 65C02-specific opcodes
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
bra,2,--,--,--,--,--,--,--,--,--,80,--,--,--,--,--
br0,2,--,--,--,--,--,--,--,--,--,0F,--,--,--,--,--
br1,2,--,--,--,--,--,--,--,--,--,1F,--,--,--,--,--
br2,2,--,--,--,--,--,--,--,--,--,2F,--,--,--,--,--
br3,2,--,--,--,--,--,--,--,--,--,3F,--,--,--,--,--
br4,2,--,--,--,--,--,--,--,--,--,4F,--,--,--,--,--
br5,2,--,--,--,--,--,--,--,--,--,5F,--,--,--,--,--
br6,2,--,--,--,--,--,--,--,--,--,6F,--,--,--,--,--
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
br7,2,--,--,--,--,--,--,--,--,--,7F,--,--,--,--,--
bs0,2,--,--,--,--,--,--,--,--,--,8F,--,--,--,--,--
bs1,2,--,--,--,--,--,--,--,--,--,9F,--,--,--,--,--
bs2,2,--,--,--,--,--,--,--,--,--,AF,--,--,--,--,--
bs3,2,--,--,--,--,--,--,--,--,--,BF,--,--,--,--,--
bs4,2,--,--,--,--,--,--,--,--,--,CF,--,--,--,--,--
bs5,2,--,--,--,--,--,--,--,--,--,DF,--,--,--,--,--
bs6,2,--,--,--,--,--,--,--,--,--,EF,--,--,--,--,--
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
bs7,2,--,--,--,--,--,--,--,--,--,FF,--,--,--,--,--
phx,2,--,--,--,--,--,--,--,--,DA,--,--,--,--,--,--
phy,2,--,--,--,--,--,--,--,--,5A,--,--,--,--,--,--
plx,2,--,--,--,--,--,--,--,--,FA,--,--,--,--,--,--
ply,2,--,--,--,--,--,--,--,--,7A,--,--,--,--,--,--
rb0,2,--,--,--,07,--,--,--,--,--,--,--,--,--,--,--
rb1,2,--,--,--,17,--,--,--,--,--,--,--,--,--,--,--
rb2,2,--,--,--,27,--,--,--,--,--,--,--,--,--,--,--
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
rb3,2,--,--,--,37,--,--,--,--,--,--,--,--,--,--,--
rb4,2,--,--,--,47,--,--,--,--,--,--,--,--,--,--,--
rb5,2,--,--,--,57,--,--,--,--,--,--,--,--,--,--,--
rb6,2,--,--,--,67,--,--,--,--,--,--,--,--,--,--,--
rb7,2,--,--,--,77,--,--,--,--,--,--,--,--,--,--,--
sb0,2,--,--,--,87,--,--,--,--,--,--,--,--,--,--,--
sb1,2,--,--,--,97,--,--,--,--,--,--,--,--,--,--,--
sb2,2,--,--,--,A7,--,--,--,--,--,--,--,--,--,--,--
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
sb3,2,--,--,--,B7,--,--,--,--,--,--,--,--,--,--,--
sb4,2,--,--,--,C7,--,--,--,--,--,--,--,--,--,--,--
sb5,2,--,--,--,D7,--,--,--,--,--,--,--,--,--,--,--
sb6,2,--,--,--,E7,--,--,--,--,--,--,--,--,--,--,--
sb7,2,--,--,--,F7,--,--,--,--,--,--,--,--,--,--,--
stp,2,--,--,--,--,--,--,--,--,DB,--,--,--,--,--,--
stz,2,--,--,9C,64,74,--,9E,--,--,--,--,--,--,--,--
trb,2,--,--,1C,14,--,--,--,--,--,--,--,--,--,--,--
;     AccImmAbsZpaZpxZpyAbxAbyImpRelInxInyAbiEmuZpi
tsb,2,--,--,0C,04,--,--,--,--,--,--,--,--,--,--,--
wai,2,--,--,--,--,--,--,--,--,CB,--,--,--,--,--,--



; The following are AmlieEm-specific debug opcodes
ere,9,--,--,--,--,--,--,--,--,--,--,--,--,--,0B
eir,9,--,--,--,--,--,--,--,--,--,--,--,--,--,1B
enm,9,--,--,--,--,--,--,--,--,--,--,--,--,--,2B
esr,9,--,--,--,--,--,--,--,--,--,--,--,--,--,3B
ezr,9,--,--,--,--,--,--,--,--,--,--,--,--,--,4B
etr,9,--,--,--,--,--,--,--,--,--,--,--,--,--,5B
; The following two are used by the breakpoint system.
; You MUST NOT use them in your own code...
; ebr,9,--,--,--,--,--,--,--,--,--,--,--,--,--,BB
; eiv,9,--,--,--,--,--,--,--,--,--,--,--,--,--,CB
eab,9,--,--,--,--,--,--,--,--,--,--,--,--,--,FB
;
; NOTE: That EIV (&CB) clashes with an 65C02 opcode
;       (WAI). This is not considered a big issue
;       as AmlieEm is an NMOS processor emulation.
;       If it is made that AmlieEm supports CMOS
;       opcodes, then EIV will be moved to &EB...
;       [you cannot assemble EIV, it is used by
;        the breakpoint system]


; END
