If you just need the size of instruction, maybe a part of my simple relocation routine may be of use for you. It can tell you addressing mode of the instruction (no OP code though, so not really usable for disassembler). It uses just 32 byte table.
Attached is full routine that uses this to perform simple
Code:
;6502 code relocation routine
;Address mode
;0 - none
;1 - immediate,relative #x
;2 - zero page ZP; ZP,X; ZP,Y; (ZP,X); (ZP),Y
;3 - abs adr; adr,X; adr,Y
;argument size in bytes
; 0 - none
; 1 - byte
; 2 - two bytes
;argument decoding (if there is one)
; 0 - immediate
; 1 - absolute address (either ZP or ABS)
; 2 - relative address (BEQ, ...)
; 3 - indirect address (either ZP or ABS) ABS only for JMP
;address register
; 0 - none
; 1 - X
; 2 - Y
;+---+---+---+---+---+---+---+---+
;| | reg | arg_t | size |
;+---+---+---+---+---+---+---+---+
I_SIZE_MASK = %11
I_ZERO = 0
I_BYTE = 1
I_WORD = 2
I_ARG_IMM = (0 << 2)
I_ADR = (1 << 2)
I_ARG_REL = (2 << 2)
I_IND = (3 << 2) ;indirect is adr+relative
I_X = (1 << 4)
I_Y = (2 << 4)
I_A = (3 << 4)
;--- modes
I_IMPL = 0
I_IMM = I_BYTE + I_ARG_IMM
I_ZP = I_BYTE + I_ADR
I_ZPX = I_BYTE + I_ADR + I_X
I_ZPY = I_BYTE + I_ADR + I_Y
I_ABS = I_WORD + I_ADR
I_ABSX = I_WORD + I_ADR + I_X
I_ABSY = I_WORD + I_ADR + I_Y
I_REL = I_BYTE + I_ARG_REL ;todo - we should have rel
I_INDX = I_BYTE + I_IND + I_X
I_INDY = I_BYTE + I_IND + I_Y
org $2000
ptr = $A0
adr = $A2
code = $a4
decode
ldy #0
lda (ptr),y
iny
tax
and #%00011111
bne regular
txa
;%xxx00000 -> %000xxx00
lsr
lsr
lsr
ora #%11 ;add 3
regular
tax
lda instr_mode_table,x
;--- now we have our addressing mode
and #I_SIZE_MASK
;--- and this is the size
rts
instr_mode_table
; this column is used for special purpose
.byte 0, I_INDX, I_IMM, I_IMM
.byte I_ZP, I_ZP, I_ZP, I_ABS
.byte I_IMPL, I_IMM, I_IMPL, I_IMPL
.byte I_ABS, I_ABS, I_ABS, I_IMPL
.byte I_REL, I_INDY, 0, 0
.byte I_ZPX, I_ZPX, I_ZPX, I_IMM
.byte I_IMPL, I_ABSY, I_IMPL, I_IMM
.byte I_ABSX, I_ABSX, I_ABSX, I_IMM