
	include	"SNES.i"

	include	"code/SNES_opcodes.i"

	incdir	"!includes:"

	include	"LVO/dos_lib.i"
	include	"LVO/intuition_lib.i"

	;a4 - high: [DB:PB], low: PC
	;a5 - high:       S, low:  P
	;d6 - high:       Y, low:  X
	;d7 - high:       D, low:  A

	;NOTE!!! If touching the SNES PC(program counter) in any way,
	;DON'T forget to use the macro CACHET before returning. This
	;corrects the true pointer.

	; macros

;Memory accessing macros

MCR_GetByte	MACRO
	jsr	EMU_GetByte
		ENDM

MCR_SetByte	MACRO
	jsr	EMU_SetByte
		ENDM

MCR_GetWord	MACRO
	jsr	EMU_GetWord
		ENDM

MCR_SetWord	MACRO
	jsr	EMU_SetWord
		ENDM

;Macros that handle-emulation modes (E/M/X)

CheckEM		MACRO

	move.l	a5,d0
	and.w	#(CPUPF_M!CPUPF_E),d0
	bne.s	.bs_\1

		ENDM

CheckE		MACRO

	move.l	a5,d0
	and.w	#(CPUPF_E),d0
	bne.s	.em_\1

		ENDM

CheckEX		MACRO

	move.l	a5,d0
	and.w	#(CPUPF_X!CPUPF_E),d0
	bne.s	.bs_\1

		ENDM

;Stack handling macros

PUSHB		MACRO	;arg: byte to push

	move.b	\1,d1

	CheckE	pb\@

	move.l	a5,d0
	swap	d0
	sub.w	#1,d0
	swap	d0
	move.l	d0,a5
	swap	d0
	and.l	#$0000ffff,d0
	MCR_SetByte

	bra	.byte_pushed\@

.em_pb\@

	move.l	a5,d0
	swap	d0
	sub.b	#1,d0
	swap	d0
	move.l	d0,a5
	swap	d0
	and.l	#$0000ffff,d0
	MCR_SetByte

.byte_pushed\@

		ENDM

PULLB		MACRO

	move.l	a5,d0
	swap	d0
	and.l	#$0000ffff,d0
	MCR_GetByte

	move.l	d0,d2

	CheckE	plb\@

	move.l	a5,d1
	swap	d1
	add.w	#1,d1
	swap	d1
	move.l	d1,a5

	bra	.byte_pulled\@

.em_plb\@

	move.l	a5,d1
	swap	d1
	add.b	#1,d1
	swap	d1
	move.l	d1,a5

.byte_pulled\@

	move.l	d2,d0

		ENDM	;d0 - byte pulled

PUSHW		MACRO	;word to push

	move.w	\1,d1

	CheckE	pw\@

	move.l	a5,d0
	swap	d0
	sub.w	#2,d0
	swap	d0
	move.l	d0,a5
	swap	d0
	and.l	#$0000ffff,d0
	MCR_SetWord

	bra	.word_pushed\@

.em_pw\@

	move.l	a5,d0
	swap	d0
	sub.b	#2,d0
	swap	d0
	move.l	d0,a5
	swap	d0
	and.l	#$0000ffff,d0
	MCR_SetWord

.word_pushed\@
		ENDM

PULLW		MACRO

	move.l	a5,d0
	swap	d0
	and.l	#$0000ffff,d0
	MCR_GetWord

	move.l	d0,d2

	CheckE	plw\@

	move.l	a5,d1
	swap	d1
	add.w	#2,d1
	swap	d1
	move.l	d1,a5

	bra	.word_pulled\@

.em_plw\@

	move.l	a5,d1
	swap	d1
	add.b	#2,d1
	swap	d1
	move.l	d1,a5

.word_pulled\@

	move.l	d2,d0

		ENDM	;d0 - Word pulled

;Argument fetch macros

GETARGB		MACRO	;args: offset to argument-1

	IFEQ	\1

	move.l	d4,d0
	rol.l	#8,d0
	and.l	#$ff,d0

	ELSE

	move.l	d4,d0
	ror.l	#8,d0
	and.l	#$ff,d0

	ENDIF

		ENDM	;d0 - byte argument

GETARGW		MACRO	;args: offset to argument-1

	move.l	d4,d0
	swap	d0
	rol.w	#8,d0
	and.l	#$ffff,d0

		ENDM	;d0 - word argument

;Stores the conditon-code flags into the P register

SCCR		MACRO	

	move.w	ccr,d0
	move.b	d0,d1
	lsl.b	#4,d1
	ror.w	#1,d0
	lsr.b	#1,d0
	rol.w	#1,d0
	rol.w	#1,d1
	lsl.b	#1,d1
	ror.w	#1,d1
	or.b	d1,d0
	move.l	a5,d1
	and.b	#~(\1),d1
	and.b	#\1,d0
	or.b	d0,d1

	IFNE	\2

	and.b	#~\2,d1

	ENDIF

	IFNE	\3

	or.b	#\3,d1

	ENDIF

	move.l	d1,a5

		ENDM

	;opcode call macro

OPCALL	MACRO	;<addrmode> <actual code>,<size b>,<cycles b>,<size w>,<cycles w>
	
	ADDRMD_\1	\2,\3,\4,\5,\6

	ENDM

	;for aligning

OPSTART	MACRO	;1 = opcode

OpStart_\1

	ENDM

OPEND	MACRO	;1 = opcode

OpSize_\1	equ	*-OpStart_\1

	ds.l	5

	ENDM

RETURNOP	MACRO	;size,cycles

	;for more easily calling the next
	;instruction w/o rts'ing.

	; increase PC

	move.l	a4,d2
	add.w	#\1,d2
	move.l	d2,a4
	add.l	#\1,a2

	btst.b	#2,$dff016
	beq	.CodeError\@

	tst.l	prg_EmulError
	bne	.CodeError\@

	; decrease cycles left and return if <0

	sub.l	#\2,d5
	bpl	.CallNext\@

.CodeError\@
	rts

.CallNext\@

	; fetch opcode

	move.l	(a2),d0
	rol.l	#8,d0
	move.l	d0,d4

	;jsr	EMU_DumpRegs

	; execute opcode

	and.l	#$ff,d0
	IFNE	DEBUG
	move.l	d0,prg_Opcode
	ENDIF
	move.l	(a0,d0*4),a1
	jmp	(a1)		;off to next opcode

		ENDM

	;macro to speedup cache testing against
	;current cpu-position

CACHET	MACRO	;size to add

	move.l	a4,d0
	and.l	#$00ffffff,d0
	jsr	EMU_GetSNESAddress
	move.l	d0,a2

	ENDM


	section	code,code

CPU_EmulateCode
* * * * * * * * * * * * * * * * * * * * * * * * *
* Emulates 65816 code.				*
*						*
* IN:	a0 - ptr to CPU structure.		*
*	d0 - Amount of cycles to run.		*
*						*
* OUT:	a0 - ptr to CPU structure		*
*	d0 - 0 if everything went ok, else ERR	*
*						*
* * * * * * * * * * * * * * * * * * * * * * * * *

	movem.l	d2-a6,-(sp)

	* Set amount of cycles

	move.l	d0,d5

	* Extract registers from CPU struct and
	* mix them into 4 registers

	lea.l	prg_CPUStructure,a0

	move.b	CPU_DB(a0),d0
	rol.w	#8,d0
	move.b	CPU_PB(a0),d0
	swap	d0
	move.w	CPU_PC(a0),d0
	move.l	d0,a4

	move.w	CPU_S(a0),d0
	swap	d0
	move.w	CPU_P(a0),d0
	move.l	d0,a5

	move.w	CPU_Y(a0),d6
	swap	d6
	move.w	CPU_X(a0),d6

	move.w	CPU_D(a0),d7
	swap	d7
	move.w	CPU_A(a0),d7

	move.l	a4,d0
	and.l	#$00ffffff,d0
	jsr	EMU_GetSNESAddress
	move.l	d0,a2

	lea.l	prg_OpCodeTable,a0
	lea.l	CCR_Table,a3

	* fetch first opcode

	move.l	(a2),d0
	rol.l	#8,d0
	move.l	d0,d4

	;jsr	EMU_DumpRegs

	* execute first opcode

	and.l	#$ff,d0
	IFNE	DEBUG
	move.l	d0,prg_Opcode
	ENDIF
	move.l	(a0,d0*4),a1
	jsr	(a1)		;returns when one frame is executed

	* Copy registers from registers and into
	* the CPU structure

	lea.l	prg_CPUStructure,a0

	move.l	prg_Opcode,CPU_Opcode(a0)

	move.l	a4,d0
	move.w	d0,CPU_PC(a0)
	swap	d0
	move.b	d0,CPU_PB(a0)
	ror.w	#8,d0
	move.b	d0,CPU_DB(a0)

	move.l	a5,d0
	move.w	d0,CPU_P(a0)
	swap	d0
	move.w	d0,CPU_S(a0)

	move.w	d6,CPU_X(a0)
	swap	d6
	move.w	d6,CPU_Y(a0)

	move.w	d7,CPU_A(a0)
	swap	d7
	move.w	d7,CPU_D(a0)

	movem.l	(sp)+,d2-a6
	move.l	prg_EmulError,d0
	rts

CPU_ExecuteInterrupt
* * * * * * * * * * * * * * * * * * * * * * * * *
* Emulates 65816 interrupt.			*
*						*
* IN:	a0 - ptr to CPU structure.		*
*	d0 - Amount of cycles to run.		*
*						*
* OUT:	a0 - ptr to CPU structure		*
*	d0 - 0 if everything went ok, else ERR	*
*	d1 - Cycles left in frame		*
*						*
* The interrupt-execution is INCORRECT, and	*
* will NOT work with code that expect certain	*
* results within the stack.			*
* * * * * * * * * * * * * * * * * * * * * * * * *

	movem.l	d2-a6,-(sp)

	* Set amount of cycles

	move.l	d0,d5

	* Extract registers from CPU struct and
	* mix them into 4 registers

	lea.l	prg_CPUStructure,a0
	lea.l	prg_ROMHeader,a1

	clr.l	d0
	move.w	RMH_VBL_Vector(a1),d0
	cmp.l	#$7fff,d0
	ble	.NoInterrupt

	move.l	d0,a4

	move.w	CPU_S(a0),d0
	swap	d0
	move.w	CPU_P(a0),d0
	btst.b	#CPUPB_I,d0
	bne	.NoInterrupt
	move.l	d0,a5

	move.w	CPU_Y(a0),d6
	swap	d6
	move.w	CPU_X(a0),d6

	move.w	CPU_D(a0),d7
	swap	d7
	move.w	CPU_A(a0),d7

	move.l	a4,d0
	and.l	#$00ffffff,d0
	jsr	EMU_GetSNESAddress
	move.l	d0,a2

	lea.l	prg_OpCodeTable,a0
	lea.l	CCR_Table,a3

	* fetch first opcode

	move.l	(a2),d0
	rol.l	#8,d0
	move.l	d0,d4

	* execute first opcode

	and.l	#$ff,d0
	IFNE	DEBUG
	move.l	d0,prg_Opcode
	ENDIF
	move.l	(a0,d0*4),a1
	jsr	(a1)		;returns when one frame is executed

	* Copy registers from registers and into
	* the CPU structure

	move.l	prg_EmulError,d0	;RTI-exception shouldn't show
	cmp.l	#EXC_RTI,d0
	bne	.OtherError

	clr.l	prg_EmulError

.OtherError

.NoInterrupt

	move.l	d5,d1
	movem.l	(sp)+,d2-a6
	move.l	prg_EmulError,d0
	rts

* * * * * * * * * * * * * * * * * * * * * * * * *
* This function-head applies to ALL opcodes.	*
*						*
* IN:	a3 - CCR Table				*
*	a4 - High: DB,PB regs, Low: PC		*
*	a5 - High: Stack ptr, Low: CPU Flags	*
*	a6 - ptr to hardware structure.		*
*	d6 - High: Y reg, Low: X reg.		*
*	d7 - High: D reg, Low: A reg.		*
*						*
* OUT:	a3 - CCR Table				*
*	a4 - High: DB,PB regs, Low: PC		*
*	a5 - High: Stack ptr, Low: CPU Flags	*
*	a6 - ptr to hardware structure.		*
*	d0 - Size of opcode.			*
*	d1 - Number of cycles executed.		*
*	d6 - High: Y reg, Low: X reg.		*
*	d7 - High: D reg, Low: A reg.		*
*						*
* * * * * * * * * * * * * * * * * * * * * * * * *

;	* = implemented

prg_OpCodeTable
	dc.l	CMD65816_BRK_STACK				;0
	dc.l	CMD65816_ORA_DIRECTINDEXINDIRECT		;1*
	dc.l	CMD65816_COP_STACK				;2
	dc.l	CMD65816_ORA_STACKRELATIVE			;3*
	dc.l	CMD65816_TSB_DIRECT				;4*
	dc.l	CMD65816_ORA_DIRECT				;5*
	dc.l	CMD65816_ASL_DIRECT				;6*
	dc.l	CMD65816_ORA_DIRECTINDIRECTLONG			;7*
	dc.l	CMD65816_PHP_STACK				;8*
	dc.l	CMD65816_ORA_IMMEDIATE				;9*
	dc.l	CMD65816_ASL_ACCUMULATOR			;10*
	dc.l	CMD65816_PHD_STACK				;11*
	dc.l	CMD65816_TSB_ABSOLUTE				;12*
	dc.l	CMD65816_ORA_ABSOLUTE				;13*
	dc.l	CMD65816_ASL_ABSOLUTE				;14*
	dc.l	CMD65816_ORA_ABSOLUTELONG			;15*
	dc.l	CMD65816_BPL_PCRELATIVE				;16*
	dc.l	CMD65816_ORA_DIRECTINDIRECTINDEX		;17*
	dc.l	CMD65816_ORA_DIRECTINDIRECT			;18*
	dc.l	CMD65816_ORA_STACKRELATIVEINDIRECTINDEX		;19*
	dc.l	CMD65816_TRB_DIRECT				;20*
	dc.l	CMD65816_ORA_DIRECTINDEX_X			;21*
	dc.l	CMD65816_ASL_DIRECTINDEX_X			;22*
	dc.l	CMD65816_ORA_DIRECTINDIRECTINDEXLONG		;23*
	dc.l	CMD65816_CLC_IMPLIED				;24*
	dc.l	CMD65816_ORA_ABSOLUTEINDEX_Y			;25*
	dc.l	CMD65816_INC_ACCUMULATOR			;26*
	dc.l	CMD65816_TCS_IMPLIED				;27*
	dc.l	CMD65816_TRB_ABSOLUTE				;28*
	dc.l	CMD65816_ORA_ABSOLUTEINDEX_X			;29*
	dc.l	CMD65816_ASL_ABSOLUTEINDEX_X			;30*
	dc.l	CMD65816_ORA_ABSOLUTEINDEXLONG			;31*
	dc.l	CMD65816_JSR_ABSOLUTE				;32*
	dc.l	CMD65816_AND_DIRECTINDEXINDIRECT		;33*
	dc.l	CMD65816_JSL_ABSOLUTELONG			;34*
	dc.l	CMD65816_AND_STACKRELATIVE			;35*
	dc.l	CMD65816_BIT_DIRECT				;36*
	dc.l	CMD65816_AND_DIRECT				;37*
	dc.l	CMD65816_ROL_DIRECT				;38*
	dc.l	CMD65816_AND_DIRECTINDIRECTLONG			;39*
	dc.l	CMD65816_PLP_STACK				;40*
	dc.l	CMD65816_AND_IMMEDIATE				;41*
	dc.l	CMD65816_ROL_ACCUMULATOR			;42*
	dc.l	CMD65816_PLD_STACK				;43*
	dc.l	CMD65816_BIT_ABSOLUTE				;44*
	dc.l	CMD65816_AND_ABSOLUTE				;45*
	dc.l	CMD65816_ROL_ABSOLUTE				;46*
	dc.l	CMD65816_AND_ABSOLUTELONG			;47*
	dc.l	CMD65816_BMI_PCRELATIVE				;48*
	dc.l	CMD65816_AND_DIRECTINDIRECTINDEX		;49*
	dc.l	CMD65816_AND_DIRECTINDIRECT			;50*
	dc.l	CMD65816_AND_STACKRELATIVEINDIRECTINDEX		;51*
	dc.l	CMD65816_BIT_DIRECTINDEX_X			;52*
	dc.l	CMD65816_AND_DIRECTINDEX_X			;53*
	dc.l	CMD65816_ROL_DIRECTINDEX_X			;54*
	dc.l	CMD65816_AND_DIRECTINDIRECTINDEXLONG		;55*
	dc.l	CMD65816_SEC_IMPLIED				;56*
	dc.l	CMD65816_AND_ABSOLUTEINDEX_Y			;57*
	dc.l	CMD65816_DEC_ACCUMULATOR			;58*
	dc.l	CMD65816_TSC_IMPLIED				;59*
	dc.l	CMD65816_BIT_ABSOLUTEINDEX_X			;60*
	dc.l	CMD65816_AND_ABSOLUTEINDEX_X			;61*
	dc.l	CMD65816_ROL_ABSOLUTEINDEX_X			;62*
	dc.l	CMD65816_AND_ABSOLUTEINDEXLONG			;63*
	dc.l	CMD65816_RTI_STACK				;64
	dc.l	CMD65816_EOR_DIRECTINDEXINDIRECT		;65*
	dc.l	CMD65816_NOOPCODE				;66*
	dc.l	CMD65816_EOR_STACKRELATIVE			;67*
	dc.l	CMD65816_MVP_BLOCKMOVE				;68
	dc.l	CMD65816_EOR_DIRECT				;69*
	dc.l	CMD65816_LSR_DIRECT				;70*
	dc.l	CMD65816_EOR_DIRECTINDIRECTLONG			;71*
	dc.l	CMD65816_PHA_STACK				;72*
	dc.l	CMD65816_EOR_IMMEDIATE				;73*
	dc.l	CMD65816_LSR_ACCUMULATOR			;74*
	dc.l	CMD65816_PHK_STACK				;75*
	dc.l	CMD65816_JMP_ABSOLUTE				;76*
	dc.l	CMD65816_EOR_ABSOLUTE				;77*
	dc.l	CMD65816_LSR_ABSOLUTE				;78*
	dc.l	CMD65816_EOR_ABSOLUTELONG			;79*
	dc.l	CMD65816_BVC_PCRELATIVE				;80*
	dc.l	CMD65816_EOR_DIRECTINDIRECTINDEX		;81*
	dc.l	CMD65816_EOR_DIRECTINDIRECT			;82*
	dc.l	CMD65816_EOR_STACKRELATIVEINDIRECTINDEX		;83*
	dc.l	CMD65816_MVN_BLOCKMOVE				;84
	dc.l	CMD65816_EOR_DIRECTINDEX_X			;85*
	dc.l	CMD65816_LSR_DIRECTINDEX_X			;86*
	dc.l	CMD65816_EOR_DIRECTINDIRECTINDEXLONG		;87*
	dc.l	CMD65816_CLI_IMPLIED				;88*
	dc.l	CMD65816_EOR_ABSOLUTEINDEX_Y			;89*
	dc.l	CMD65816_PHY_STACK				;90*
	dc.l	CMD65816_TCD_IMPLIED				;91*
	dc.l	CMD65816_JMP_ABSOLUTELONG			;92*
	dc.l	CMD65816_EOR_ABSOLUTEINDEX_X			;93*
	dc.l	CMD65816_LSR_ABSOLUTEINDEX_X			;94*
	dc.l	CMD65816_EOR_ABSOLUTEINDEXLONG			;95*
	dc.l	CMD65816_RTS_STACK				;96*
	dc.l	CMD65816_ADC_DIRECTINDEXINDIRECT		;97*
	dc.l	CMD65816_PER_STACK				;98*
	dc.l	CMD65816_ADC_STACKRELATIVE			;99*
	dc.l	CMD65816_STZ_DIRECT				;100*
	dc.l	CMD65816_ADC_DIRECT				;101*
	dc.l	CMD65816_ROR_DIRECT				;102*
	dc.l	CMD65816_ADC_DIRECTINDIRECTLONG			;103*
	dc.l	CMD65816_PLA_STACK				;104*
	dc.l	CMD65816_ADC_IMMEDIATE				;105*
	dc.l	CMD65816_ROR_ACCUMULATOR			;106*
	dc.l	CMD65816_RTL_STACK				;107*
	dc.l	CMD65816_JMP_ABSOLUTEINDIRECT			;108*
	dc.l	CMD65816_ADC_ABSOLUTE				;109*
	dc.l	CMD65816_ROR_ABSOLUTE				;110*
	dc.l	CMD65816_ADC_ABSOLUTELONG			;111*
	dc.l	CMD65816_BVS_PCRELATIVE				;112*
	dc.l	CMD65816_ADC_DIRECTINDIRECTINDEX		;113*
	dc.l	CMD65816_ADC_DIRECTINDIRECT			;114*
	dc.l	CMD65816_ADC_STACKRELATIVEINDIRECTINDEX		;115*
	dc.l	CMD65816_STZ_DIRECTINDEX_X			;116*
	dc.l	CMD65816_ADC_DIRECTINDEX_X			;117*
	dc.l	CMD65816_ROR_DIRECTINDEX_X			;118*
	dc.l	CMD65816_ADC_DIRECTINDIRECTINDEXLONG		;119*
	dc.l	CMD65816_SEI_IMPLIED				;120*
	dc.l	CMD65816_ADC_ABSOLUTEINDEX_Y			;121*
	dc.l	CMD65816_PLY_STACK				;122*
	dc.l	CMD65816_TDC_IMPLIED				;123*
	dc.l	CMD65816_JMP_ABSOLUTEINDEXEDINDIRECT		;124*
	dc.l	CMD65816_ADC_ABSOLUTEINDEX_X			;125*
	dc.l	CMD65816_ROR_ABSOLUTEINDEX_X			;126*
	dc.l	CMD65816_ADC_ABSOLUTEINDEXLONG			;127*
	dc.l	CMD65816_BRA_PCRELATIVE				;128*
	dc.l	CMD65816_STA_DIRECTINDEXINDIRECT		;129*
	dc.l	CMD65816_BRL_PCRELATIVELONG			;130*
	dc.l	CMD65816_STA_STACKRELATIVE			;131*
	dc.l	CMD65816_STY_DIRECT				;132*
	dc.l	CMD65816_STA_DIRECT				;133*
	dc.l	CMD65816_STX_DIRECT				;134*
	dc.l	CMD65816_STA_DIRECTINDIRECTLONG			;135*
	dc.l	CMD65816_DEY_IMPLIED				;136*
	dc.l	CMD65816_BIT_IMMEDIATE				;137*
	dc.l	CMD65816_TXA_IMPLIED				;138*
	dc.l	CMD65816_PHB_STACK				;139*
	dc.l	CMD65816_STY_ABSOLUTE				;140*
	dc.l	CMD65816_STA_ABSOLUTE				;141*
	dc.l	CMD65816_STX_ABSOLUTE				;142*
	dc.l	CMD65816_STA_ABSOLUTELONG			;143*
	dc.l	CMD65816_BCC_PCRELATIVE				;144*
	dc.l	CMD65816_STA_DIRECTINDIRECTINDEX		;145*
	dc.l	CMD65816_STA_DIRECTINDIRECT			;146*
	dc.l	CMD65816_STA_STACKRELATIVEINDIRECTINDEX		;147*
	dc.l	CMD65816_STY_DIRECTINDEX_X			;148*
	dc.l	CMD65816_STA_DIRECTINDEX_X			;149*
	dc.l	CMD65816_STX_DIRECTINDEX_Y			;150*
	dc.l	CMD65816_STA_DIRECTINDIRECTINDEXLONG		;151*
	dc.l	CMD65816_TYA_IMPLIED				;152*
	dc.l	CMD65816_STA_ABSOLUTEINDEX_Y			;153*
	dc.l	CMD65816_TXS_IMPLIED				;154*
	dc.l	CMD65816_TXY_IMPLIED				;155*
	dc.l	CMD65816_STZ_ABSOLUTE				;156*
	dc.l	CMD65816_STA_ABSOLUTEINDEX_X			;157*
	dc.l	CMD65816_STZ_ABSOLUTEINDEX_X			;158*
	dc.l	CMD65816_STA_ABSOLUTEINDEXLONG			;159*
	dc.l	CMD65816_LDY_IMMEDIATE				;160*
	dc.l	CMD65816_LDA_DIRECTINDEXINDIRECT		;161*
	dc.l	CMD65816_LDX_IMMEDIATE				;162*
	dc.l	CMD65816_LDA_STACKRELATIVE			;163*
	dc.l	CMD65816_LDY_DIRECT				;164*
	dc.l	CMD65816_LDA_DIRECT				;165*
	dc.l	CMD65816_LDX_DIRECT				;166*
	dc.l	CMD65816_LDA_DIRECTINDIRECTLONG			;167*
	dc.l	CMD65816_TAY_IMPLIED				;168*
	dc.l	CMD65816_LDA_IMMEDIATE				;169*
	dc.l	CMD65816_TAX_IMPLIED				;170*
	dc.l	CMD65816_PLB_STACK				;171*
	dc.l	CMD65816_LDY_ABSOLUTE				;172*
	dc.l	CMD65816_LDA_ABSOLUTE				;173*
	dc.l	CMD65816_LDX_ABSOLUTE				;174*
	dc.l	CMD65816_LDA_ABSOLUTELONG			;175*
	dc.l	CMD65816_BCS_PCRELATIVE				;176*
	dc.l	CMD65816_LDA_DIRECTINDIRECTINDEX		;177*
	dc.l	CMD65816_LDA_DIRECTINDIRECT			;178*
	dc.l	CMD65816_LDA_STACKRELATIVEINDIRECTINDEX		;179*
	dc.l	CMD65816_LDY_DIRECTINDEX_X			;180*
	dc.l	CMD65816_LDA_DIRECTINDEX_X			;181*
	dc.l	CMD65816_LDX_DIRECTINDEX_Y			;182*
	dc.l	CMD65816_LDA_DIRECTINDIRECTINDEXLONG		;183*
	dc.l	CMD65816_CLV_IMPLIED				;184*
	dc.l	CMD65816_LDA_ABSOLUTEINDEX_Y			;185*
	dc.l	CMD65816_TSX_IMPLIED				;186*
	dc.l	CMD65816_TYX_IMPLIED				;187*
	dc.l	CMD65816_LDY_ABSOLUTEINDEX_X			;188*
	dc.l	CMD65816_LDA_ABSOLUTEINDEX_X			;189*
	dc.l	CMD65816_LDX_ABSOLUTEINDEX_Y			;190*
	dc.l	CMD65816_LDA_ABSOLUTEINDEXLONG			;191*
	dc.l	CMD65816_CPY_IMMEDIATE				;192*
	dc.l	CMD65816_CMP_DIRECTINDEXINDIRECT		;193*
	dc.l	CMD65816_REP_IMMEDIATE				;194*
	dc.l	CMD65816_CMP_STACKRELATIVE			;195*
	dc.l	CMD65816_CPY_DIRECT				;196*
	dc.l	CMD65816_CMP_DIRECT				;197*
	dc.l	CMD65816_DEC_DIRECT				;198*
	dc.l	CMD65816_CMP_DIRECTINDIRECTLONG			;199*
	dc.l	CMD65816_INY_IMPLIED				;200*
	dc.l	CMD65816_CMP_IMMEDIATE				;201*
	dc.l	CMD65816_DEX_IMPLIED				;202*
	dc.l	CMD65816_WAI_IMPLIED				;203*
	dc.l	CMD65816_CPY_ABSOLUTE				;204*
	dc.l	CMD65816_CMP_ABSOLUTE				;205*
	dc.l	CMD65816_DEC_ABSOLUTE				;206*
	dc.l	CMD65816_CMP_ABSOLUTELONG			;207*
	dc.l	CMD65816_BNE_PCRELATIVE				;208*
	dc.l	CMD65816_CMP_DIRECTINDIRECTINDEX		;209*
	dc.l	CMD65816_CMP_DIRECTINDIRECT			;210*
	dc.l	CMD65816_CMP_STACKRELATIVEINDIRECTINDEX		;211*
	dc.l	CMD65816_PEI_STACK				;212*
	dc.l	CMD65816_CMP_DIRECTINDEX_X			;213*
	dc.l	CMD65816_DEC_DIRECTINDEX_X			;214*
	dc.l	CMD65816_CMP_DIRECTINDIRECTINDEXLONG		;215*
	dc.l	CMD65816_CLD_IMPLIED				;216*
	dc.l	CMD65816_CMP_ABSOLUTEINDEX_Y			;217*
	dc.l	CMD65816_PHX_STACK				;218*
	dc.l	CMD65816_STP_IMPLIED				;219*
	dc.l	CMD65816_JML_ABSOLUTEINDIRECT			;220*
	dc.l	CMD65816_CMP_ABSOLUTEINDEX_X			;221*
	dc.l	CMD65816_DEC_ABSOLUTEINDEX_X			;222*
	dc.l	CMD65816_CMP_ABSOLUTEINDEXLONG			;223*
	dc.l	CMD65816_CPX_IMMEDIATE				;224*
	dc.l	CMD65816_SBC_DIRECTINDEXINDIRECT		;225*
	dc.l	CMD65816_SEP_IMMEDIATE				;226*
	dc.l	CMD65816_SBC_STACKRELATIVE			;227*
	dc.l	CMD65816_CPX_DIRECT				;228*
	dc.l	CMD65816_SBC_DIRECT				;229*
	dc.l	CMD65816_INC_DIRECT				;230*
	dc.l	CMD65816_SBC_DIRECTINDIRECTLONG			;231*
	dc.l	CMD65816_INX_IMPLIED				;232*
	dc.l	CMD65816_SBC_IMMEDIATE				;233*
	dc.l	CMD65816_NOP_IMPLIED				;234*
	dc.l	CMD65816_XBA_IMPLIED				;235*
	dc.l	CMD65816_CPX_ABSOLUTE				;236*
	dc.l	CMD65816_SBC_ABSOLUTE				;237*
	dc.l	CMD65816_INC_ABSOLUTE				;238*
	dc.l	CMD65816_SBC_ABSOLUTELONG			;239*
	dc.l	CMD65816_BEQ_PCRELATIVE				;240*
	dc.l	CMD65816_SBC_DIRECTINDIRECTINDEX		;241*
	dc.l	CMD65816_SBC_DIRECTINDIRECT			;242*
	dc.l	CMD65816_SBC_STACKRELATIVEINDIRECTINDEX		;243*
	dc.l	CMD65816_PEA_STACK				;244*
	dc.l	CMD65816_SBC_DIRECTINDEX_X			;245*
	dc.l	CMD65816_INC_DIRECTINDEX_X			;246*
	dc.l	CMD65816_SBC_DIRECTINDIRECTINDEXLONG		;247*
	dc.l	CMD65816_SED_IMPLIED				;248*
	dc.l	CMD65816_SBC_ABSOLUTEINDEX_Y			;249*
	dc.l	CMD65816_PLX_STACK				;250*
	dc.l	CMD65816_XCE_IMPLIED				;251*
	dc.l	CMD65816_JSR_ABSOLUTEINDEXEDINDIRECT		;252*
	dc.l	CMD65816_SBC_ABSOLUTEINDEX_X			;253*
	dc.l	CMD65816_INC_ABSOLUTEINDEX_X			;254*
	dc.l	CMD65816_SBC_ABSOLUTEINDEXLONG			;255*

CMD65816_BRK_STACK
	;Force Break
	OPSTART	0
	move.l	#EXC_UNIMPL,prg_EmulError
	rts
	OPEND	0


CMD65816_ORA_DIRECTINDEXINDIRECT
	;"OR" Memory with Accumulator
	OPSTART	1
	OPCALL	DIRECTINDEXINDIRECT,ORA,2,6,2,6
	OPEND	1


CMD65816_COP_STACK
	;Coprocessor
	OPSTART	2
	move.l	#EXC_UNIMPL,prg_EmulError
	rts
	OPEND	2


CMD65816_ORA_STACKRELATIVE
	;"OR" Memory with Accumulator
	OPSTART	3
	OPCALL	STACKRELATIVE,ORA,2,4,2,4
	OPEND	3


CMD65816_TSB_DIRECT
	;Test and Set Bit
	OPSTART	4
	OPCALL	DIRECT,TSB,2,5,2,5
	OPEND	4


CMD65816_ORA_DIRECT
	;"OR" Memory with Accumulator
	OPSTART	5
	OPCALL	DIRECT,ORA,2,3,2,3
	OPEND	5


CMD65816_ASL_DIRECT
	;Shift One Bit Left, Memory or Accumulator
	OPSTART	6
	OPCALL	DIRECT,ASL,2,5,2,5
	OPEND	6


CMD65816_ORA_DIRECTINDIRECTLONG
	;"OR" Memory with Accumulator
	OPSTART	7
	OPCALL	DIRECTINDIRECTLONG,ORA,2,6,2,6
	OPEND	7


CMD65816_PHP_STACK
	;Push Processor Status on Stack
	OPSTART	8
	move.l	a5,d0
	PUSHB	d0

	RETURNOP	1,3
	OPEND	8


CMD65816_ORA_IMMEDIATE
	;"OR" Memory with Accumulator
	OPSTART	9
	CheckEM	ora_immediate

	GETARGW	0
	or.w	d0,d7
	SCCR	%10000010,0,0
	RETURNOP	3,2

.bs_ora_immediate

	GETARGB	0
	or.b	d0,d7
	SCCR	%10000010,0,0
	RETURNOP	2,2
	OPEND	9


CMD65816_ASL_ACCUMULATOR
	;Shift One Bit Left, Memory or Accumulator
	OPSTART	10
	OPCALL	ACCUMULATOR,ASL,1,2,1,2
	OPEND	10


CMD65816_PHD_STACK
	;Push Direct Register on Stack
	OPSTART	11
	swap	d7
	PUSHW	d7
	swap	d7

	RETURNOP	1,4
	OPEND	11


CMD65816_TSB_ABSOLUTE
	;Test and Set Bit
	OPSTART	12
	OPCALL	ABSOLUTE,TSB,3,6,3,6
	OPEND	12


CMD65816_ORA_ABSOLUTE
	;"OR" Memory with Accumulator
	OPSTART	13
	OPCALL	ABSOLUTE,ORA,3,4,3,4
	OPEND	13


CMD65816_ASL_ABSOLUTE
	;Shift One Bit Left, Memory or Accumulator
	OPSTART	14
	OPCALL	ABSOLUTE,ASL,3,6,3,6
	OPEND	14


CMD65816_ORA_ABSOLUTELONG
	;"OR" Memory with Accumulator
	OPSTART	15
	OPCALL	ABSOLUTELONG,ORA,4,5,4,5
	OPEND	15


CMD65816_BPL_PCRELATIVE
	;Branch if Result Plus (PN = 0)
	OPSTART	16
	move.l	a5,d0
	and.w	#(CPUPF_N),d0
	beq	.taken_bpl_pcrelative

	RETURNOP	2,2

.taken_bpl_pcrelative

	GETARGB	0
	ext.w	d0
	move.l	a4,d1
	add.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	2,3
	OPEND	16


CMD65816_ORA_DIRECTINDIRECTINDEX
	;"OR" Memory with Accumulator
	OPSTART	17
	OPCALL	DIRECTINDIRECTINDEX,ORA,2,5,2,5
	OPEND	17


CMD65816_ORA_DIRECTINDIRECT
	;"OR" Memory with Accumulator
	OPSTART	18
	OPCALL	DIRECTINDIRECT,ORA,2,5,2,5
	OPEND	18


CMD65816_ORA_STACKRELATIVEINDIRECTINDEX
	;"OR" Memory with Accumulator
	OPSTART	19
	OPCALL	STACKRELATIVEINDIRECTINDEX,ORA,2,7,2,7
	OPEND	19


CMD65816_TRB_DIRECT
	;Test and Reset Bit
	OPSTART	20
	OPCALL	DIRECT,TRB,2,5,2,5
	OPEND	20


CMD65816_ORA_DIRECTINDEX_X
	;"OR" Memory with Accumulator
	OPSTART	21
	OPCALL	DIRECTINDEX_X,ORA,2,4,2,4
	OPEND	21


CMD65816_ASL_DIRECTINDEX_X
	;Shift One Bit Left, Memory or Accumulator
	OPSTART	22
	OPCALL	DIRECTINDEX_X,ASL,2,6,2,6
	OPEND	22


CMD65816_ORA_DIRECTINDIRECTINDEXLONG
	;"OR" Memory with Accumulator
	OPSTART	23
	OPCALL	DIRECTINDIRECTINDEXLONG,ORA,2,6,2,6
	OPEND	23


CMD65816_CLC_IMPLIED
	;Clear Carry Flag
	OPSTART	24
	move.l	a5,d0
	and.b	#~CPUPF_C,d0
	move.l	d0,a5
	RETURNOP	1,2
	OPEND	24


CMD65816_ORA_ABSOLUTEINDEX_Y
	;"OR" Memory with Accumulator
	OPSTART	25
	OPCALL	ABSOLUTEINDEX_Y,ORA,3,4,3,4
	OPEND	25


CMD65816_INC_ACCUMULATOR
	;Increment Memory or Accumulator by One
	OPSTART	26
	OPCALL	ACCUMULATOR,INC,1,2,1,2
	OPEND	26


CMD65816_TCS_IMPLIED
	;Transfer Accumulator to Stack Pointer Register
	OPSTART	27
	move.l	a5,d0
	swap	d0
	move.w	d7,d0
	swap	d0
	move.l	d0,a5
	RETURNOP	1,2
	OPEND	27


CMD65816_TRB_ABSOLUTE
	;Test and Reset Bit
	OPSTART	28
	OPCALL	ABSOLUTE,TRB,3,6,3,6
	OPEND	28


CMD65816_ORA_ABSOLUTEINDEX_X
	;"OR" Memory with Accumulator
	OPSTART	29
	OPCALL	ABSOLUTEINDEX_X,ORA,3,4,3,4
	OPEND	29


CMD65816_ASL_ABSOLUTEINDEX_X
	;Shift One Bit Left, Memory or Accumulator
	OPSTART	30
	OPCALL	ABSOLUTEINDEX_X,ASL,3,7,3,7
	OPEND	30


CMD65816_ORA_ABSOLUTEINDEXLONG
	;"OR" Memory with Accumulator
	OPSTART	31
	OPCALL	ABSOLUTEINDEXLONG,ORA,4,5,4,5
	OPEND	31


CMD65816_JSR_ABSOLUTE
	;Jump to New Location Saving Return Address
	OPSTART	32
	GETARGW	0
	move.l	d0,d3

	move.l	a4,d4
	add.w	#3,d4
	PUSHW	d4
	move.w	d3,d4

	move.l	d4,a4

	CACHET

	RETURNOP	0,6
	OPEND	32


CMD65816_AND_DIRECTINDEXINDIRECT
	;"AND" Memory with Accumulator
	OPSTART	33
	OPCALL	DIRECTINDEXINDIRECT,AND,2,6,2,6
	OPEND	33


CMD65816_JSL_ABSOLUTELONG
	;Jump Subroutine Long
	OPSTART	34
	GETARGW	0
	move.l	d0,d1
	GETARGB	2
	rol.l	#8,d0
	rol.l	#8,d0
	move.w	d1,d0
	move.l	d0,d4

	move.l	a4,d0
	swap	d0
	PUSHB	d0
	move.l	a4,d1
	add.w	#4,d1
	PUSHW	d1

	move.l	a4,d1
	and.l	#$ff000000,d1
	and.l	#$00ffffff,d4
	or.l	d4,d1
	move.l	d1,a4

	CACHET

	RETURNOP	0,8
	OPEND	34


CMD65816_AND_STACKRELATIVE
	;"AND" Memory with Accumulator
	OPSTART	35
	OPCALL	STACKRELATIVE,AND,2,4,2,4
	OPEND	35


CMD65816_BIT_DIRECT
	;Bit Test
	OPSTART	36
	OPCALL	DIRECT,BIT,2,3,2,3
	OPEND	36


CMD65816_AND_DIRECT
	;"AND" Memory with Accumulator
	OPSTART	37
	OPCALL	DIRECT,AND,2,3,2,3
	OPEND	37


CMD65816_ROL_DIRECT
	;Rotate One Bit Left (Memory or Accumulator)
	OPSTART	38
	OPCALL	DIRECT,ROL,2,5,2,5
	OPEND	38


CMD65816_AND_DIRECTINDIRECTLONG
	;"AND" Memory with Accumulator
	OPSTART	39
	OPCALL	DIRECTINDIRECTLONG,AND,2,6,2,6
	OPEND	39


CMD65816_PLP_STACK
	;Pull Processor Status from Stack
	OPSTART	40
	PULLB
	move.l	a5,d1
	move.b	d0,d1
	move.l	d1,a5
	RETURNOP	1,4
	OPEND	40


CMD65816_AND_IMMEDIATE
	;"AND" Memory with Accumulator
	OPSTART	41
	CheckEM	and_immediate

	GETARGW	0
	and.w	d0,d7

	SCCR	%10000010,0,0

	RETURNOP	3,2

.bs_and_immediate

	GETARGB	0
	and.b	d0,d7
	SCCR	%10000010,0,0

	RETURNOP	2,2
	OPEND	41


CMD65816_ROL_ACCUMULATOR
	;Rotate One Bit Left (Memory or Accumulator)
	OPSTART	42
	OPCALL	ACCUMULATOR,ROL,1,2,1,2
	OPEND	42


CMD65816_PLD_STACK
	;Pull Direct Register from Stack
	OPSTART	43
	PULLW
	swap	d7
	move.w	d0,d7
	SCCR	%10000010,0,0
	swap	d7
	RETURNOP	1,5
	OPEND	43


CMD65816_BIT_ABSOLUTE
	;Bit Test
	OPSTART	44
	OPCALL	ABSOLUTE,BIT,3,4,3,4
	OPEND	44


CMD65816_AND_ABSOLUTE
	;"AND" Memory with Accumulator
	OPSTART	45
	OPCALL	ABSOLUTE,AND,3,4,3,4
	OPEND	45


CMD65816_ROL_ABSOLUTE
	;Rotate One Bit Left (Memory or Accumulator)
	OPSTART	46
	OPCALL	ABSOLUTE,ROL,3,6,3,6
	OPEND	46


CMD65816_AND_ABSOLUTELONG
	;"AND" Memory with Accumulator
	OPSTART	47
	OPCALL	ABSOLUTELONG,AND,4,5,4,5
	OPEND	47


CMD65816_BMI_PCRELATIVE
	;Branch if Result Minus (PN = 1)
	OPSTART	48
	move.l	a5,d0
	and.w	#(CPUPF_N),d0
	bne	.taken_bmi_pcrelative

	RETURNOP	2,2

.taken_bmi_pcrelative

	GETARGB	0
	ext.w	d0
	move.l	a4,d1
	add.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	2,3
	OPEND	48


CMD65816_AND_DIRECTINDIRECTINDEX
	;"AND" Memory with Accumulator
	OPSTART	49
	OPCALL	DIRECTINDIRECTINDEX,AND,2,5,2,5
	OPEND	49


CMD65816_AND_DIRECTINDIRECT
	;"AND" Memory with Accumulator
	OPSTART	50
	OPCALL	DIRECTINDIRECT,AND,2,5,2,5
	OPEND	50


CMD65816_AND_STACKRELATIVEINDIRECTINDEX
	;"AND" Memory with Accumulator
	OPSTART	51
	OPCALL	STACKRELATIVEINDIRECTINDEX,AND,2,7,2,7
	OPEND	51


CMD65816_BIT_DIRECTINDEX_X
	;Bit Test
	OPSTART	52
	OPCALL	DIRECTINDEX_X,BIT,2,4,2,4
	OPEND	52


CMD65816_AND_DIRECTINDEX_X
	;"AND" Memory with Accumulator
	OPSTART	53
	OPCALL	DIRECTINDEX_X,AND,2,4,2,4
	OPEND	53


CMD65816_ROL_DIRECTINDEX_X
	;Rotate One Bit Left (Memory or Accumulator)
	OPSTART	54
	OPCALL	DIRECTINDEX_X,ROL,2,6,2,6
	OPEND	54


CMD65816_AND_DIRECTINDIRECTINDEXLONG
	;"AND" Memory with Accumulator
	OPSTART	55
	OPCALL	DIRECTINDIRECTINDEXLONG,AND,2,6,2,6
	OPEND	55


CMD65816_SEC_IMPLIED
	;Set Carry Flag
	OPSTART	56
	move.l	a5,d0
	or.b	#CPUPF_C,d0
	move.l	d0,a5
	RETURNOP	1,2
	OPEND	56


CMD65816_AND_ABSOLUTEINDEX_Y
	;"AND" Memory with Accumulator
	OPSTART	57
	OPCALL	ABSOLUTEINDEX_Y,AND,3,4,3,4
	OPEND	57


CMD65816_DEC_ACCUMULATOR
	;Decrement Memory or Accumulator by One
	OPSTART	58
	OPCALL	ACCUMULATOR,DEC,1,2,1,2
	OPEND	58


CMD65816_TSC_IMPLIED
	;Transfer Stack Pointer Register to Accumulator
	OPSTART	59
	move.l	a5,d0
	swap	d0
	move.w	d0,d7
	SCCR	%10000010,0,0
	RETURNOP	1,2
	OPEND	59


CMD65816_BIT_ABSOLUTEINDEX_X
	;Bit Test
	OPSTART	60
	OPCALL	ABSOLUTEINDEX_X,BIT,3,4,3,4
	OPEND	60


CMD65816_AND_ABSOLUTEINDEX_X
	;"AND" Memory with Accumulator
	OPSTART	61
	OPCALL	ABSOLUTEINDEX_X,AND,3,4,3,4
	OPEND	61


CMD65816_ROL_ABSOLUTEINDEX_X
	;Rotate One Bit Left (Memory or Accumulator)
	OPSTART	62
	OPCALL	ABSOLUTEINDEX_X,ROL,3,7,3,7
	OPEND	62


CMD65816_AND_ABSOLUTEINDEXLONG
	;"AND" Memory with Accumulator
	OPSTART	63
	OPCALL	ABSOLUTEINDEXLONG,AND,4,5,4,5
	OPEND	63


CMD65816_RTI_STACK
	;Return from Interrupt
	OPSTART	64
	move.l	#EXC_RTI,prg_EmulError
	rts
	OPEND	64


CMD65816_EOR_DIRECTINDEXINDIRECT
	;Exclusive "OR" Memory with Accumulator
	OPSTART	65
	OPCALL	DIRECTINDEXINDIRECT,EOR,2,6,2,6
	OPEND	65


CMD65816_NOOPCODE
	;No description of opcode
	OPSTART	66
	RETURNOP	2,2
	OPEND	66


CMD65816_EOR_STACKRELATIVE
	;Exclusive "OR" Memory with Accumulator
	OPSTART	67
	OPCALL	STACKRELATIVE,EOR,2,4,2,4
	OPEND	67


CMD65816_MVP_BLOCKMOVE
	;Block Move Positive
	OPSTART	68
	BREAKPOINT	EXC_UNIMPL
	RETURNOP	3,7
	OPEND	68


CMD65816_EOR_DIRECT
	;Exclusive "OR" Memory with Accumulator
	OPSTART	69
	OPCALL	DIRECT,EOR,2,3,2,3
	OPEND	69


CMD65816_LSR_DIRECT
	;Shift One Bit Right (Memory or Accumulator)
	OPSTART	70
	OPCALL	DIRECT,LSR,2,5,2,5
	OPEND	70


CMD65816_EOR_DIRECTINDIRECTLONG
	;Exclusive "OR" Memory with Accumulator
	OPSTART	71
	OPCALL	DIRECTINDIRECTLONG,EOR,2,6,2,6
	OPEND	71


CMD65816_PHA_STACK
	;Push Accumulator on Stack
	OPSTART	72
	CheckEM	pha_stack

	PUSHW	d7
	RETURNOP	1,3

.bs_pha_stack

	PUSHB	d7
	RETURNOP	1,3
	OPEND	72


CMD65816_EOR_IMMEDIATE
	;Exclusive "OR" Memory with Accumulator
	OPSTART	73
	CheckEM	eor_immediate

	GETARGW	0
	eor.w	d0,d7
	SCCR	%10000010,0,0

	RETURNOP	3,2

.bs_eor_immediate

	GETARGB	0
	eor.b	d0,d7
	SCCR	%10000010,0,0

	RETURNOP	2,2
	OPEND	73


CMD65816_LSR_ACCUMULATOR
	;Shift One Bit Right (Memory or Accumulator)
	OPSTART	74
	OPCALL	ACCUMULATOR,LSR,1,2,1,2
	OPEND	74


CMD65816_PHK_STACK
	;Push Program Bank Register on Stack
	OPSTART	75
	move.l	a4,d1
	swap	d1
	and.l	#$ff,d1
	PUSHB	d1
	RETURNOP	1,3
	OPEND	75


CMD65816_JMP_ABSOLUTE
	;Jump to New Location
	OPSTART	76
	GETARGW	0
	move.l	a4,d1
	lsr.l	#8,d1
	move.w	d0,d1
	move.l	d1,d0

	move.l	a4,d3
	move.w	d0,d3
	move.l	d3,a4

	CACHET

	RETURNOP	0,3
	OPEND	76


CMD65816_EOR_ABSOLUTE
	;Exclusive "OR" Memory with Accumulator
	OPSTART	77
	OPCALL	ABSOLUTE,EOR,3,4,3,4
	OPEND	77


CMD65816_LSR_ABSOLUTE
	;Shift One Bit Right (Memory or Accumulator)
	OPSTART	78
	OPCALL	ABSOLUTE,LSR,3,6,3,6
	OPEND	78


CMD65816_EOR_ABSOLUTELONG
	;Exclusive "OR" Memory with Accumulator
	OPSTART	79
	OPCALL	ABSOLUTELONG,EOR,4,5,4,5
	OPEND	79


CMD65816_BVC_PCRELATIVE
	;Branch on Overflow Clear (Pv = 0)
	OPSTART	80
	move.l	a5,d0
	and.w	#(CPUPF_V),d0
	beq	.taken_bvc_pcrelative

	RETURNOP	2,2

.taken_bvc_pcrelative

	GETARGB	0
	ext.w	d0
	move.l	a4,d1
	add.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	2,3
	OPEND	80


CMD65816_EOR_DIRECTINDIRECTINDEX
	;Exclusive "OR" Memory with Accumulator
	OPSTART	81
	OPCALL	DIRECTINDIRECTINDEX,EOR,2,5,2,5
	OPEND	81


CMD65816_EOR_DIRECTINDIRECT
	;Exclusive "OR" Memory with Accumulator
	OPSTART	82
	OPCALL	DIRECTINDIRECT,EOR,2,5,2,5
	OPEND	82


CMD65816_EOR_STACKRELATIVEINDIRECTINDEX
	;Exclusive "OR" Memory with Accumulator
	OPSTART	83
	OPCALL	STACKRELATIVEINDIRECTINDEX,EOR,2,7,2,7
	OPEND	83


CMD65816_MVN_BLOCKMOVE
	;Block Move Negative
	OPSTART	84
	BREAKPOINT	EXC_UNIMPL

	RETURNOP	3,7
	OPEND	84


CMD65816_EOR_DIRECTINDEX_X
	;Exclusive "OR" Memory with Accumulator
	OPSTART	85
	OPCALL	DIRECTINDEX_X,EOR,2,4,2,4
	OPEND	85


CMD65816_LSR_DIRECTINDEX_X
	;Shift One Bit Right (Memory or Accumulator)
	OPSTART	86
	OPCALL	DIRECTINDEX_X,LSR,2,6,2,6
	OPEND	86


CMD65816_EOR_DIRECTINDIRECTINDEXLONG
	;Exclusive "OR" Memory with Accumulator
	OPSTART	87
	OPCALL	DIRECTINDIRECTINDEXLONG,EOR,2,6,2,6
	OPEND	87


CMD65816_CLI_IMPLIED
	;Clear Interrupt Disable Bit
	OPSTART	88
	move.l	a5,d0
	and.b	#~CPUPF_I,d0
	move.l	d0,a5
	RETURNOP	1,2
	OPEND	88


CMD65816_EOR_ABSOLUTEINDEX_Y
	;Exclusive "OR" Memory with Accumulator
	OPSTART	89
	OPCALL	ABSOLUTEINDEX_Y,EOR,3,4,3,4
	OPEND	89


CMD65816_PHY_STACK
	;Push index Y on Stack
	OPSTART	90
	CheckEX	phy_stack

	swap	d6
	PUSHW	d6
	swap	d6

	RETURNOP	1,3

.bs_phy_stack

	swap	d6
	PUSHB	d6
	swap	d6

	RETURNOP	1,3
	OPEND	90


CMD65816_TCD_IMPLIED
	;Transfer Accumulator to Direct Register
	OPSTART	91
	move.w	d7,d0
	swap	d0
	move.w	d0,d7
	RETURNOP	1,2
	OPEND	91


CMD65816_JMP_ABSOLUTELONG
	;Jump to New Location
	OPSTART	92
	GETARGW	0
	move.l	d0,d1
	GETARGB	2
	rol.l	#8,d0
	rol.l	#8,d0
	move.w	d1,d0

	move.l	a4,d3
	and.l	#$00ffffff,d0
	and.l	#$ff000000,d3
	or.l	d0,d3
	move.l	d3,a4

	CACHET

	RETURNOP	0,4
	OPEND	92


CMD65816_EOR_ABSOLUTEINDEX_X
	;Exclusive "OR" Memory with Accumulator
	OPSTART	93
	OPCALL	ABSOLUTEINDEX_X,EOR,3,4,3,4
	OPEND	93


CMD65816_LSR_ABSOLUTEINDEX_X
	;Shift One Bit Right (Memory or Accumulator)
	OPSTART	94
	OPCALL	ABSOLUTEINDEX_X,LSR,3,7,3,7
	OPEND	94


CMD65816_EOR_ABSOLUTEINDEXLONG
	;Exclusive "OR" Memory with Accumulator
	OPSTART	95
	OPCALL	ABSOLUTEINDEXLONG,EOR,4,5,4,5
	OPEND	95


CMD65816_RTS_STACK
	;Return from Subroutine
	OPSTART	96
	PULLW
	move.l	a4,d1
	move.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	0,6
	OPEND	96


CMD65816_ADC_DIRECTINDEXINDIRECT
	;Add Memory to Accumulator with Carry
	OPSTART	97
	OPCALL	DIRECTINDEXINDIRECT,ADC,2,6,2,6
	OPEND	97


CMD65816_PER_STACK
	;Push Effective Program Counter Relative Address on Stack
	OPSTART	98
	GETARGW
	move.l	a4,d1
	add.w	#3,d1
	add.w	d1,d0
	PUSHW	d0

	RETURNOP	3,6
	OPEND	98


CMD65816_ADC_STACKRELATIVE
	;Add Memory to Accumulator with Carry
	OPSTART	99
	OPCALL	STACKRELATIVE,ADC,2,4,2,4
	OPEND	99


CMD65816_STZ_DIRECT
	;Store Zero in Memory
	OPSTART	100
	OPCALL	DIRECT,STZ,2,3,2,3
	OPEND	100


CMD65816_ADC_DIRECT
	;Add Memory to Accumulator with Carry
	OPSTART	101
	OPCALL	DIRECT,ADC,2,3,2,3
	OPEND	101


CMD65816_ROR_DIRECT
	;Rotate One Bit Right (Memory or Accumulator)
	OPSTART	102
	OPCALL	DIRECT,ROR,2,5,2,5
	OPEND	102


CMD65816_ADC_DIRECTINDIRECTLONG
	;Add Memory to Accumulator with Carry
	OPSTART	103
	OPCALL	DIRECTINDIRECTLONG,ADC,2,6,2,6
	OPEND	103


CMD65816_PLA_STACK
	;Pull Accumulator from Stack
	OPSTART	104
	CheckEM	pla_stack

	PULLW
	move.w	d0,d7
	SCCR	%10000010,0,0

	RETURNOP	1,4

.bs_pla_stack

	PULLB
	move.b	d0,d7
	SCCR	%10000010,0,0

	RETURNOP	1,4
	OPEND	104


CMD65816_ADC_IMMEDIATE
	;Add Memory to Accumulator with Carry
	OPSTART	105
	CheckEM	adc_immediate

	GETARGW	0
	move.w	a5,d1
	and.w	#$0001,d1
	;add.w	d1,d0
	add.w	d0,d7
	SCCR	%11000011,0,0
	RETURNOP	3,2

.bs_adc_immediate

	GETARGB	0
	move.w	a5,d1
	and.w	#$0001,d1
	;add.b	d1,d0
	add.b	d0,d7
	SCCR	%11000011,0,0
	RETURNOP	2,2
	OPEND	105


CMD65816_ROR_ACCUMULATOR
	;Rotate One Bit Right (Memory or Accumulator)
	OPSTART	106
	OPCALL	ACCUMULATOR,ROR,1,2,1,2
	OPEND	106


CMD65816_RTL_STACK
	;Return from Subroutine Long
	OPSTART	107
	PULLW
	move.l	d0,d3
	PULLB
	swap	d0
	move.w	d3,d0

	move.l	a4,d1
	and.l	#$ff000000,d1
	and.l	#$00ffffff,d0
	or.l	d1,d0
	move.l	d0,a4

	CACHET

	RETURNOP	0,6
	OPEND	107


CMD65816_JMP_ABSOLUTEINDIRECT
	;Jump to New Location
	OPSTART	108
	GETARGW
	MCR_GetWord
	move.l	a4,d1
	move.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	0,5
	OPEND	108


CMD65816_ADC_ABSOLUTE
	;Add Memory to Accumulator with Carry
	OPSTART	109
	OPCALL	ABSOLUTE,ADC,3,4,3,4
	OPEND	109


CMD65816_ROR_ABSOLUTE
	;Rotate One Bit Right (Memory or Accumulator)
	OPSTART	110
	OPCALL	ABSOLUTE,ROR,3,6,3,6
	OPEND	110


CMD65816_ADC_ABSOLUTELONG
	;Add Memory to Accumulator with Carry
	OPSTART	111
	OPCALL	ABSOLUTELONG,ADC,4,5,4,5
	OPEND	111


CMD65816_BVS_PCRELATIVE
	;Branch on Overflow Set (Pv = 1)
	OPSTART	112
	move.l	a5,d0
	and.w	#(CPUPF_V),d0
	bne	.taken_bvs_pcrelative

	RETURNOP	2,2

.taken_bvs_pcrelative

	GETARGB	0
	ext.w	d0
	move.l	a4,d1
	add.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	2,3
	OPEND	112


CMD65816_ADC_DIRECTINDIRECTINDEX
	;Add Memory to Accumulator with Carry
	OPSTART	113
	OPCALL	DIRECTINDIRECTINDEX,ADC,2,5,2,5
	OPEND	113


CMD65816_ADC_DIRECTINDIRECT
	;Add Memory to Accumulator with Carry
	OPSTART	114
	OPCALL	DIRECTINDIRECT,ADC,2,5,2,5
	OPEND	114


CMD65816_ADC_STACKRELATIVEINDIRECTINDEX
	;Add Memory to Accumulator with Carry
	OPSTART	115
	OPCALL	STACKRELATIVEINDIRECTINDEX,ADC,2,7,2,7
	OPEND	115


CMD65816_STZ_DIRECTINDEX_X
	;Store Zero in Memory
	OPSTART	116
	OPCALL	DIRECTINDEX_X,STZ,2,4,2,4
	OPEND	116


CMD65816_ADC_DIRECTINDEX_X
	;Add Memory to Accumulator with Carry
	OPSTART	117
	OPCALL	DIRECTINDEX_X,ADC,2,4,2,4
	OPEND	117


CMD65816_ROR_DIRECTINDEX_X
	;Rotate One Bit Right (Memory or Accumulator)
	OPSTART	118
	OPCALL	DIRECTINDEX_X,ROR,2,6,2,6
	OPEND	118


CMD65816_ADC_DIRECTINDIRECTINDEXLONG
	;Add Memory to Accumulator with Carry
	OPSTART	119
	OPCALL	DIRECTINDIRECTINDEXLONG,ADC,2,6,2,6
	OPEND	119


CMD65816_SEI_IMPLIED
	;Set Interrupt Disable Status
	OPSTART	120
	move.l	a5,d0
	or.b	#CPUPF_I,d0
	move.l	d0,a5

	RETURNOP	1,2
	OPEND	120


CMD65816_ADC_ABSOLUTEINDEX_Y
	;Add Memory to Accumulator with Carry
	OPSTART	121
	OPCALL	ABSOLUTEINDEX_Y,ADC,3,4,3,4
	OPEND	121


CMD65816_PLY_STACK
	;Pull Index Y form Stack
	OPSTART	122
	CheckEX	ply_stack

	PULLW
	swap	d6
	move.w	d0,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,4

.bs_ply_stack

	PULLB
	swap	d6
	move.b	d0,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,4
	OPEND	122


CMD65816_TDC_IMPLIED
	;Transfer Direct Register to Accumulator
	OPSTART	123
	swap	d7
	move.w	d7,d0
	swap	d7
	move.w	d0,d7
	SCCR	%10000010,0,0

	RETURNOP	1,2
	OPEND	123


CMD65816_JMP_ABSOLUTEINDEXEDINDIRECT
	;Jump to New Location
	OPSTART	124
	GETARGW
	move.l	a4,d1
	and.l	#$00ff0000,d1
	move.w	d0,d1
	add.w	d6,d1
	move.l	d1,d0
	MCR_GetWord

	move.l	a4,d1
	move.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	0,6
	OPEND	124


CMD65816_ADC_ABSOLUTEINDEX_X
	;Add Memory to Accumulator with Carry
	OPSTART	125
	OPCALL	ABSOLUTEINDEX_X,ADC,3,4,3,4
	OPEND	125


CMD65816_ROR_ABSOLUTEINDEX_X
	;Rotate One Bit Right (Memory or Accumulator)
	OPSTART	126
	OPCALL	ABSOLUTEINDEX_X,ROR,3,7,3,7
	OPEND	126


CMD65816_ADC_ABSOLUTEINDEXLONG
	;Add Memory to Accumulator with Carry
	OPSTART	127
	OPCALL	ABSOLUTEINDEXLONG,ADC,4,5,4,5
	OPEND	127


CMD65816_BRA_PCRELATIVE
	;Branch Always
	OPSTART	128
	GETARGB	0
	ext.w	d0
	move.l	a4,d1
	add.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	2,2
	OPEND	128


CMD65816_STA_DIRECTINDEXINDIRECT
	;Store Accumulator in Memory
	OPSTART	129
	OPCALL	DIRECTINDEXINDIRECT,STA,2,6,2,6
	OPEND	129


CMD65816_BRL_PCRELATIVELONG
	;Branch Always Long
	OPSTART	130
	GETARGW	0
	move.l	a4,d1
	add.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	3,3
	OPEND	130


CMD65816_STA_STACKRELATIVE
	;Store Accumulator in Memory
	OPSTART	131
	OPCALL	STACKRELATIVE,STA,2,4,2,4
	OPEND	131


CMD65816_STY_DIRECT
	;Store Index Y in Memory
	OPSTART	132
	CheckEX	sty_direct

	GETARGB	0
	move.l	d7,d1
	swap	d1
	add.w	d1,d0

	move.l	d6,d1
	swap	d1
	MCR_SetWord

	RETURNOP	2,3

.bs_sty_direct

	GETARGB	0
	move.l	d7,d1
	swap	d1
	add.w	d1,d0

	move.l	d6,d1
	swap	d1
	MCR_SetByte

	RETURNOP	2,3
	OPEND	132


CMD65816_STA_DIRECT
	;Store Accumulator in Memory
	OPSTART	133
	OPCALL	DIRECT,STA,2,3,2,3
	OPEND	133


CMD65816_STX_DIRECT
	;Store Index X in Memory
	OPSTART	134
	CheckEX	stx_direct

	GETARGB	0
	move.l	d7,d1
	swap	d1
	add.w	d1,d0

	move.w	d6,d1
	MCR_SetWord

	RETURNOP	2,3

.bs_stx_direct

	GETARGB	0
	move.l	d7,d1
	swap	d1
	add.w	d1,d0

	move.b	d6,d1
	MCR_SetByte

	RETURNOP	2,3
	OPEND	134


CMD65816_STA_DIRECTINDIRECTLONG
	;Store Accumulator in Memory
	OPSTART	135
	OPCALL	DIRECTINDIRECTLONG,STA,2,6,2,6
	OPEND	135


CMD65816_DEY_IMPLIED
	;Decrement Index Y by One
	OPSTART	136
	CheckEX	dey_implied

	swap	d6
	sub.w	#1,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,2

.bs_dey_implied

	swap	d6
	sub.b	#1,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,2
	OPEND	136


CMD65816_BIT_IMMEDIATE
	;Bit Test
	OPSTART	137
	CheckEM	bit_immediate

	GETARGW
	and.w	d7,d0
	SCCR	%00000010,0,0

	RETURNOP	2,2

.bs_bit_immediate

	GETARGB	0
	and.b	d7,d0
	SCCR	%00000010,0,0

	RETURNOP	2,2
	OPEND	137


CMD65816_TXA_IMPLIED
	;Transfer Index X to Accumulator
	OPSTART	138
	CheckEM	txa_implied

	move.w	d6,d7
	SCCR	%10000010,0,0

	RETURNOP	1,2

.bs_txa_implied

	move.b	d6,d7
	SCCR	%10000010,0,0

	RETURNOP	1,2
	OPEND	138


CMD65816_PHB_STACK
	;Push Data Bank Register on Stack
	OPSTART	139
	move.l	a4,d0
	swap	d0
	lsr.w	#8,d0
	PUSHB	d0

	RETURNOP	1,3
	OPEND	139


CMD65816_STY_ABSOLUTE
	;Store Index Y in Memory
	OPSTART	140
	CheckEX	sty_absolute

	GETARGW	0

	move.l	a4,d1
	lsr.l	#8,d1
	move.w	d0,d1
	move.l	d1,d0

	move.l	d6,d1
	swap	d1
	MCR_SetWord

	RETURNOP	3,4

.bs_sty_absolute

	GETARGW	0

	move.l	a4,d1
	lsr.l	#8,d1
	move.w	d0,d1
	move.l	d1,d0

	move.l	d6,d1
	swap	d1
	MCR_SetByte

	RETURNOP	3,4
	OPEND	140


CMD65816_STA_ABSOLUTE
	;Store Accumulator in Memory
	OPSTART	141
	OPCALL	ABSOLUTE,STA,3,4,3,4
	OPEND	141


CMD65816_STX_ABSOLUTE
	;Store Index X in Memory
	OPSTART	142
	CheckEX	stx_absolute

	GETARGW	0

	move.l	a4,d1
	lsr.l	#8,d1
	move.w	d0,d1
	move.l	d1,d0

	move.w	d6,d1
	MCR_SetWord

	RETURNOP	3,4

.bs_stx_absolute

	GETARGW	0

	move.l	a4,d1
	lsr.l	#8,d1
	move.w	d0,d1
	move.l	d1,d0

	move.b	d6,d1
	MCR_SetByte

	RETURNOP	3,4
	OPEND	142


CMD65816_STA_ABSOLUTELONG
	;Store Accumulator in Memory
	OPSTART	143
	OPCALL	ABSOLUTELONG,STA,4,5,4,5
	OPEND	143


CMD65816_BCC_PCRELATIVE
	;Branch on Carry Clear (Pe = O)
	OPSTART	144
	move.l	a5,d0
	and.w	#(CPUPF_C),d0
	beq	.taken_bcc_pcrelative

	RETURNOP	2,2

.taken_bcc_pcrelative

	GETARGB	0
	ext.w	d0
	move.l	a4,d1
	add.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	2,3
	OPEND	144


CMD65816_STA_DIRECTINDIRECTINDEX
	;Store Accumulator in Memory
	OPSTART	145
	OPCALL	DIRECTINDIRECTINDEX,STA,2,6,2,6
	OPEND	145


CMD65816_STA_DIRECTINDIRECT
	;Store Accumulator in Memory
	OPSTART	146
	OPCALL	DIRECTINDIRECT,STA,2,5,2,5
	OPEND	146


CMD65816_STA_STACKRELATIVEINDIRECTINDEX
	;Store Accumulator in Memory
	OPSTART	147
	OPCALL	STACKRELATIVEINDIRECTINDEX,STA,2,7,2,7
	OPEND	147


CMD65816_STY_DIRECTINDEX_X
	;Store Index Y in Memory
	OPSTART	148
	CheckEX	sty_directindex_x

	GETARGB	0
	move.l	d7,d1
	swap	d1
	add.w	d1,d0
	add.w	d6,d0

	move.l	d6,d1
	swap	d1
	MCR_SetWord

	RETURNOP	2,4

.bs_sty_directindex_x

	GETARGB	0
	move.l	d7,d1
	swap	d1
	add.w	d1,d0
	add.w	d6,d0

	move.l	d6,d1
	swap	d1
	MCR_SetByte

	RETURNOP	2,4
	OPEND	148


CMD65816_STA_DIRECTINDEX_X
	;Store Accumulator in Memory
	OPSTART	149
	OPCALL	DIRECTINDEX_X,STA,2,4,2,4
	OPEND	149


CMD65816_STX_DIRECTINDEX_Y
	;Store Index X in Memory
	OPSTART	150
	CheckEX	stx_directindex_y

	GETARGB	0
	move.l	d7,d1
	swap	d1
	add.w	d1,d0
	swap	d6
	add.w	d6,d0
	swap	d6

	move.w	d6,d1
	MCR_SetWord

	RETURNOP	2,4

.bs_stx_directindex_y

	GETARGB	0
	move.l	d7,d1
	swap	d1
	add.w	d1,d0
	swap	d6
	add.w	d6,d0
	swap	d6

	move.b	d6,d1
	MCR_SetByte

	RETURNOP	2,4
	OPEND	150


CMD65816_STA_DIRECTINDIRECTINDEXLONG
	;Store Accumulator in Memory
	OPSTART	151
	OPCALL	DIRECTINDIRECTINDEXLONG,STA,2,6,2,6
	OPEND	151


CMD65816_TYA_IMPLIED
	;Transfer Index Y to Accumulator
	OPSTART	152
	CheckEM	tya_implied

	swap	d6
	move.w	d6,d7
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,2

.bs_tya_implied

	swap	d6
	move.b	d6,d7
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,2
	OPEND	152


CMD65816_STA_ABSOLUTEINDEX_Y
	;Store Accumulator in Memory
	OPSTART	153
	OPCALL	ABSOLUTEINDEX_Y,STA,3,5,3,5
	OPEND	153


CMD65816_TXS_IMPLIED
	;Transfer Index X to Stack Polnter Register
	OPSTART	154
	CheckE	txs_implied

	move.l	a5,d0
	swap	d0
	move.w	d6,d0
	swap	d0
	move.l	d0,a5

	RETURNOP	1,2

.em_txs_implied

	move.l	a5,d0
	swap	d0
	move.w	#$0100,d0
	move.b	d6,d0
	swap	d0
	move.l	d0,a5

	RETURNOP	1,2
	OPEND	154


CMD65816_TXY_IMPLIED
	;Transfer Index X to Index Y
	OPSTART	155
	CheckEX	txy_implied

	move.w	d6,d0
	swap	d6
	move.w	d0,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,2

.bs_txy_implied

	move.b	d6,d0
	swap	d6
	move.b	d0,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,2
	OPEND	155


CMD65816_STZ_ABSOLUTE
	;Store Zero in Memory
	OPSTART	156
	OPCALL	ABSOLUTE,STZ,3,4,3,4
	OPEND	156


CMD65816_STA_ABSOLUTEINDEX_X
	;Store Accumulator in Memory
	OPSTART	157
	OPCALL	ABSOLUTEINDEX_X,STA,3,5,3,5
	OPEND	157


CMD65816_STZ_ABSOLUTEINDEX_X
	;Store Zero in Memory
	OPSTART	158
	OPCALL	ABSOLUTEINDEX_X,STZ,3,5,3,5
	OPEND	158


CMD65816_STA_ABSOLUTEINDEXLONG
	;Store Accumulator in Memory
	OPSTART	159
	OPCALL	ABSOLUTEINDEXLONG,STA,4,5,4,5
	OPEND	159


CMD65816_LDY_IMMEDIATE
	;Load Index Y with Memory
	OPSTART	160
	CheckEX	ldy_immediate

	GETARGW	0
	swap	d6
	move.w	d0,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	3,2

.bs_ldy_immediate

	GETARGB	0
	swap	d6
	move.b	d0,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	2,2
	OPEND	160


CMD65816_LDA_DIRECTINDEXINDIRECT
	;Load Accumulator with Memory
	OPSTART	161
	OPCALL	DIRECTINDEXINDIRECT,LDA,2,6,2,6
	OPEND	161


CMD65816_LDX_IMMEDIATE
	;Load Index X with Memory
	OPSTART	162
	CheckEX	ldx_immediate

	GETARGW	0
	move.w	d0,d6
	SCCR	%10000010,0,0

	RETURNOP	3,2

.bs_ldx_immediate

	GETARGB	0
	move.b	d0,d6
	SCCR	%10000010,0,0

	RETURNOP	2,2
	OPEND	162


CMD65816_LDA_STACKRELATIVE
	;Load Accumulator with Memory
	OPSTART	163
	OPCALL	STACKRELATIVE,LDA,2,4,2,4
	OPEND	163


CMD65816_LDY_DIRECT
	;Load Index Y with Memory
	OPSTART	164
	OPCALL	DIRECT,LDY,2,3,2,3
	OPEND	164


CMD65816_LDA_DIRECT
	;Load Accumulator with Memory
	OPSTART	165
	OPCALL	DIRECT,LDA,2,3,2,3
	OPEND	165


CMD65816_LDX_DIRECT
	;Load Index X with Memory
	OPSTART	166
	OPCALL	DIRECT,LDX,2,3,2,3
	OPEND	166


CMD65816_LDA_DIRECTINDIRECTLONG
	;Load Accumulator with Memory
	OPSTART	167
	OPCALL	DIRECTINDIRECTLONG,LDA,2,6,2,6
	OPEND	167


CMD65816_TAY_IMPLIED
	;Transfer Accumulator to Index Y
	OPSTART	168
	CheckEX	tay_implied

	swap	d6
	move.w	d7,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,2

.bs_tay_implied

	swap	d6
	move.b	d7,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,2
	OPEND	168


CMD65816_LDA_IMMEDIATE
	;Load Accumulator with Memory
	OPSTART	169
	CheckEM	lda_immediate

	GETARGW	0
	move.w	d0,d7
	SCCR	%10000010,0,0

	RETURNOP	3,2

.bs_lda_immediate

	GETARGB	0
	move.b	d0,d7
	SCCR	%10000010,0,0

	RETURNOP	2,2
	OPEND	169


CMD65816_TAX_IMPLIED
	;Transfer Accumulator to Index X
	OPSTART	170
	CheckEX	tax_implied

	move.w	d7,d6
	SCCR	%10000010,0,0

	RETURNOP	1,2

.bs_tax_implied

	move.b	d7,d6
	SCCR	%10000010,0,0

	RETURNOP	1,2
	OPEND	170


CMD65816_PLB_STACK
	;Pull Data Bank Register from Stack
	OPSTART	171
	PULLB
	move.l	a4,d2
	swap	d2
	ror.w	#8,d2
	move.b	d0,d2
	SCCR	%10000010,0,0
	rol.w	#8,d2
	swap	d2
	move.l	d2,a4

	RETURNOP	1,2
	OPEND	171


CMD65816_LDY_ABSOLUTE
	;Load Index Y with Memory
	OPSTART	172
	OPCALL	ABSOLUTE,LDY,3,4,3,4
	OPEND	172


CMD65816_LDA_ABSOLUTE
	;Load Accumulator with Memory
	OPSTART	173
	OPCALL	ABSOLUTE,LDA,3,4,3,4
	OPEND	173


CMD65816_LDX_ABSOLUTE
	;Load Index X with Memory
	OPSTART	174
	OPCALL	ABSOLUTE,LDX,3,4,3,4
	OPEND	174


CMD65816_LDA_ABSOLUTELONG
	;Load Accumulator with Memory
	OPSTART	175
	OPCALL	ABSOLUTELONG,LDA,4,5,4,5
	OPEND	175


CMD65816_BCS_PCRELATIVE
	;Branch on Carry Set (Pe = 1)
	OPSTART	176
	move.l	a5,d0
	and.w	#(CPUPF_C),d0
	bne	.taken_bcs_pcrelative

	RETURNOP	2,2

.taken_bcs_pcrelative

	GETARGB	0
	ext.w	d0
	move.l	a4,d1
	add.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	2,3
	OPEND	176


CMD65816_LDA_DIRECTINDIRECTINDEX
	;Load Accumulator with Memory
	OPSTART	177
	OPCALL	DIRECTINDIRECTINDEX,LDA,2,5,2,5
	OPEND	177


CMD65816_LDA_DIRECTINDIRECT
	;Load Accumulator with Memory
	OPSTART	178
	OPCALL	DIRECTINDIRECT,LDA,2,5,2,5
	OPEND	178


CMD65816_LDA_STACKRELATIVEINDIRECTINDEX
	;Load Accumulator with Memory
	OPSTART	179
	OPCALL	STACKRELATIVEINDIRECTINDEX,LDA,2,7,2,7
	OPEND	179


CMD65816_LDY_DIRECTINDEX_X
	;Load Index Y with Memory
	OPSTART	180
	OPCALL	DIRECTINDEX_X,LDY,2,4,2,4
	OPEND	180


CMD65816_LDA_DIRECTINDEX_X
	;Load Accumulator with Memory
	OPSTART	181
	OPCALL	DIRECTINDEX_X,LDA,2,4,2,4
	OPEND	181


CMD65816_LDX_DIRECTINDEX_Y
	;Load Index X with Memory
	OPSTART	182
	OPCALL	DIRECTINDEX_Y,LDX,2,4,2,4
	OPEND	182


CMD65816_LDA_DIRECTINDIRECTINDEXLONG
	;Load Accumulator with Memory
	OPSTART	183
	OPCALL	DIRECTINDIRECTINDEXLONG,LDA,2,6,2,6
	OPEND	183


CMD65816_CLV_IMPLIED
	;Clear Overflow Flag
	OPSTART	184
	move.l	a5,d0
	and.b	#~CPUPF_V,d0
	move.l	d0,a5

	RETURNOP	1,2
	OPEND	184


CMD65816_LDA_ABSOLUTEINDEX_Y
	;Load Accumulator with Memory
	OPSTART	185
	OPCALL	ABSOLUTEINDEX_Y,LDA,3,4,3,4
	OPEND	185


CMD65816_TSX_IMPLIED
	;Transfer Stack Pointer Register to Index X
	OPSTART	186
	CheckEX	tsx_implied

	move.l	a5,d0
	swap	d0
	move.w	d0,d6
	SCCR	%10000010,0,0

	RETURNOP	1,2

.bs_tsx_implied

	move.l	a5,d0
	swap	d0
	move.b	d0,d6
	SCCR	%10000010,0,0

	RETURNOP	1,2
	OPEND	186


CMD65816_TYX_IMPLIED
	;Transfer Index Y to Index X
	OPSTART	187
	CheckEX	tyx_implied

	swap	d6
	move.w	d6,d0
	swap	d6
	move.w	d0,d6
	SCCR	%10000010,0,0

	RETURNOP	1,2

.bs_tyx_implied

	swap	d6
	move.b	d6,d0
	swap	d6
	move.b	d0,d6
	SCCR	%10000010,0,0

	RETURNOP	1,2
	OPEND	187


CMD65816_LDY_ABSOLUTEINDEX_X
	;Load Index Y with Memory
	OPSTART	188
	OPCALL	ABSOLUTEINDEX_X,LDY,3,4,3,4
	OPEND	188


CMD65816_LDA_ABSOLUTEINDEX_X
	;Load Accumulator with Memory
	OPSTART	189
	OPCALL	ABSOLUTEINDEX_X,LDA,3,4,3,4
	OPEND	189


CMD65816_LDX_ABSOLUTEINDEX_Y
	;Load Index X with Memory
	OPSTART	190
	OPCALL	ABSOLUTEINDEX_Y,LDX,3,4,3,4
	OPEND	190


CMD65816_LDA_ABSOLUTEINDEXLONG
	;Load Accumulator with Memory
	OPSTART	191
	OPCALL	ABSOLUTEINDEXLONG,LDA,4,5,4,5
	OPEND	191


CMD65816_CPY_IMMEDIATE
	;Compare Memory and Index Y
	OPSTART	192
	CheckEX	cpy_immediate

	GETARGW	0
	swap	d6
	cmp.w	d0,d6
	SCCR	%10000011,0,0
	swap	d6

	RETURNOP	3,2

.bs_cpy_immediate

	GETARGB	0
	swap	d6
	cmp.b	d0,d6
	SCCR	%10000011,0,0
	swap	d6

	RETURNOP	2,2
	OPEND	192


CMD65816_CMP_DIRECTINDEXINDIRECT
	;Compare Memory and Accumulator
	OPSTART	193
	OPCALL	DIRECTINDEXINDIRECT,CMP,2,6,2,6
	OPEND	193


CMD65816_REP_IMMEDIATE
	;Reset Status Bits
	OPSTART	194
	GETARGB	0

	move.l	a5,d1
	not.b	d0
	and.b	d0,d1
	move.l	d1,a5

	RETURNOP	2,3
	OPEND	194


CMD65816_CMP_STACKRELATIVE
	;Compare Memory and Accumulator
	OPSTART	195
	OPCALL	STACKRELATIVE,CMP,2,4,2,4
	OPEND	195


CMD65816_CPY_DIRECT
	;Compare Memory and Index Y
	OPSTART	196
	CheckEX	cpy_direct

	GETARGB	0
	move.l	d7,d1
	swap	d1
	and.l	#$ffff,d1
	add.l	d1,d0
	and.l	#$ffff,d0

	MCR_GetWord
	swap	d6
	cmp.w	d0,d6
	SCCR	%10000011,0,0
	swap	d6

	RETURNOP	2,3

.bs_cpy_direct

	GETARGB	0
	move.l	d7,d1
	swap	d1
	and.l	#$ffff,d1
	add.l	d1,d0
	and.l	#$ffff,d0

	MCR_GetByte
	swap	d6
	cmp.b	d0,d6
	SCCR	%10000011,0,0
	swap	d6

	RETURNOP	2,3
	OPEND	196


CMD65816_CMP_DIRECT
	;Compare Memory and Accumulator
	OPSTART	197
	OPCALL	DIRECT,CMP,2,3,2,3
	OPEND	197


CMD65816_DEC_DIRECT
	;Decrement Memory or Accumulator by One
	OPSTART	198
	OPCALL	DIRECT,DEC,2,5,2,5
	OPEND	198


CMD65816_CMP_DIRECTINDIRECTLONG
	;Compare Memory and Accumulator
	OPSTART	199
	OPCALL	DIRECTINDIRECTLONG,CMP,2,6,2,6
	OPEND	199


CMD65816_INY_IMPLIED
	;Increment Index Y by One
	OPSTART	200
	CheckEX	iny_implied

	swap	d6
	add.w	#1,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,2

.bs_iny_implied

	swap	d6
	add.b	#1,d6
	SCCR	%10000010,0,0
	swap	d6

	RETURNOP	1,2
	OPEND	200


CMD65816_CMP_IMMEDIATE
	;Compare Memory and Accumulator
	OPSTART	201
	CheckEM	cmp_immediate

	GETARGW	0
	cmp.w	d0,d7
	SCCR	%10000011,0,0

	RETURNOP	3,2

.bs_cmp_immediate

	GETARGB	0
	cmp.b	d0,d7
	SCCR	%10000011,0,0

	RETURNOP	2,2
	OPEND	201


CMD65816_DEX_IMPLIED
	;Decrement Index X by One
	OPSTART	202
	CheckEX	dex_implied

	sub.w	#1,d6
	SCCR	%10000010,0,0

	RETURNOP	1,2

.bs_dex_implied

	sub.b	#1,d6
	SCCR	%10000010,0,0

	RETURNOP	1,2
	OPEND	202


CMD65816_WAI_IMPLIED
	;Wait for Interrupt
	OPSTART	203
	move.l	#-1,d5

	RETURNOP	1,3
	OPEND	203


CMD65816_CPY_ABSOLUTE
	;Compare Memory and Index Y
	OPSTART	204
	CheckEX	cpy_absolute

	GETARGW	0

	move.l	a4,d1
	lsr.l	#8,d1
	move.w	d0,d1
	move.l	d1,d0

	MCR_GetWord
	swap	d6
	cmp.w	d0,d6
	SCCR	%10000011,0,0
	swap	d6

	RETURNOP	3,4

.bs_cpy_absolute

	GETARGW	0

	move.l	a4,d1
	lsr.l	#8,d1
	move.w	d0,d1
	move.l	d1,d0

	MCR_GetByte
	swap	d6
	cmp.b	d0,d6
	SCCR	%10000011,0,0
	swap	d6

	RETURNOP	3,4
	OPEND	204


CMD65816_CMP_ABSOLUTE
	;Compare Memory and Accumulator
	OPSTART	205
	OPCALL	ABSOLUTE,CMP,3,4,3,4
	OPEND	205


CMD65816_DEC_ABSOLUTE
	;Decrement Memory or Accumulator by One
	OPSTART	206
	OPCALL	ABSOLUTE,DEC,3,4,3,4
	OPEND	206


CMD65816_CMP_ABSOLUTELONG
	;Compare Memory and Accumulator
	OPSTART	207
	OPCALL	ABSOLUTELONG,CMP,4,5,4,5
	OPEND	207


CMD65816_BNE_PCRELATIVE
	;Branch if Not Equal (Pz = 0)
	OPSTART	208
	move.l	a5,d0
	and.w	#(CPUPF_Z),d0
	beq	.taken_bne_pcrelative

	RETURNOP	2,2

.taken_bne_pcrelative

	GETARGB	0
	ext.w	d0
	move.l	a4,d1

	move.l	d1,d2

	add.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	2,3
	OPEND	208


CMD65816_CMP_DIRECTINDIRECTINDEX
	;Compare Memory and Accumulator
	OPSTART	209
	OPCALL	DIRECTINDIRECTINDEX,CMP,2,5,2,5
	OPEND	209


CMD65816_CMP_DIRECTINDIRECT
	;Compare Memory and Accumulator
	OPSTART	210
	OPCALL	DIRECTINDIRECT,CMP,2,5,2,5
	OPEND	210


CMD65816_CMP_STACKRELATIVEINDIRECTINDEX
	;Compare Memory and Accumulator
	OPSTART	211
	OPCALL	STACKRELATIVEINDIRECTINDEX,CMP,2,7,2,7
	OPEND	211


CMD65816_PEI_STACK
	;Push Effective Indirect Address on Stack (add one cycle if DL f 0)
	OPSTART	212
	GETARGB	0
	swap	d7
	add.w	d7,d0
	swap	d7
	MCR_GetWord
	move.l	a4,d1
	ror.l	#8,d1
	and.l	#$00ff0000,d1
	or.l	d1,d0
	MCR_GetWord
	PUSHW	d0

	RETURNOP	2,6
	OPEND	212


CMD65816_CMP_DIRECTINDEX_X
	;Compare Memory and Accumulator
	OPSTART	213
	OPCALL	DIRECTINDEX_X,CMP,2,4,2,4
	OPEND	213


CMD65816_DEC_DIRECTINDEX_X
	;Decrement Memory or Accumulator by One
	OPSTART	214
	OPCALL	DIRECTINDEX_X,DEC,2,6,2,6
	OPEND	214


CMD65816_CMP_DIRECTINDIRECTINDEXLONG
	;Compare Memory and Accumulator
	OPSTART	215
	OPCALL	DIRECTINDIRECTINDEXLONG,CMP,2,6,2,6
	OPEND	215


CMD65816_CLD_IMPLIED
	;Clear Decimal Mode
	OPSTART	216
	move.l	a5,d0
	and.b	#~CPUPF_D,d0
	move.l	d0,a5

	RETURNOP	1,2
	OPEND	216


CMD65816_CMP_ABSOLUTEINDEX_Y
	;Compare Memory and Accumulator
	OPSTART	217
	OPCALL	ABSOLUTEINDEX_Y,CMP,3,4,3,4
	OPEND	217


CMD65816_PHX_STACK
	;Push Index X on Stack
	OPSTART	218
	CheckEX	phx_stack

	PUSHW	d6

	RETURNOP	1,3

.bs_phx_stack

	PUSHB	d6

	RETURNOP	1,3
	OPEND	218


CMD65816_STP_IMPLIED
	;Stop the Clock
	OPSTART	219
	move.l	#EXC_STOPCLOCK,prg_EmulError
	rts
	OPEND	219


CMD65816_JML_ABSOLUTEINDIRECT
	;Jump Long
	OPSTART	220
	GETARGW
	move.l	d0,d4
	MCR_GetWord
	move.l	d0,d3
	move.l	d4,d0
	add.l	#2,d0
	MCR_GetByte
	swap	d0
	move.w	d3,d0	

	move.l	a4,d1
	and.l	#$ff000000,d1
	or.l	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	0,6
	OPEND	220


CMD65816_CMP_ABSOLUTEINDEX_X
	;Compare Memory and Accumulator
	OPSTART	221
	OPCALL	ABSOLUTEINDEX_X,CMP,3,4,3,4
	OPEND	221


CMD65816_DEC_ABSOLUTEINDEX_X
	;Decrement Memory or Accumulator by One
	OPSTART	222
	OPCALL	ABSOLUTEINDEX_X,DEC,3,7,3,7
	OPEND	222


CMD65816_CMP_ABSOLUTEINDEXLONG
	;Compare Memory and Accumulator
	OPSTART	223
	OPCALL	ABSOLUTEINDEXLONG,CMP,4,5,4,5
	OPEND	223


CMD65816_CPX_IMMEDIATE
	;Compare Memory and Index X
	OPSTART	224
	CheckEX	cpx_immediate

	GETARGW	0
	cmp.w	d0,d6
	SCCR	%10000011,0,0


	RETURNOP	3,2

.bs_cpx_immediate

	GETARGB	0
	cmp.b	d0,d6
	SCCR	%10000011,0,0

	RETURNOP	2,2
	OPEND	224


CMD65816_SBC_DIRECTINDEXINDIRECT
	;Subtract Memory from Accumulator with Borrow
	OPSTART	225
	OPCALL	DIRECTINDEXINDIRECT,SBC,2,6,2,6
	OPEND	225


CMD65816_SEP_IMMEDIATE
	;Set Processor Status Bits
	OPSTART	226
	GETARGB	0
	move.l	a5,d1
	or.b	d0,d1
	move.l	d1,a5

	btst.b	#CPUPF_X,d1
	beq	.not_IndexEmulation

	and.l	#$00ff00ff,d6

.not_IndexEmulation

	RETURNOP	2,3
	OPEND	226


CMD65816_SBC_STACKRELATIVE
	;Subtract Memory from Accumulator with Borrow
	OPSTART	227
	OPCALL	STACKRELATIVE,SBC,2,4,2,4
	OPEND	227


CMD65816_CPX_DIRECT
	;Compare Memory and Index X
	OPSTART	228
	;OPCALL	DIRECT,CPX,2,3,2,3
	RETURNOP	2,3
	OPEND	228


CMD65816_SBC_DIRECT
	;Subtract Memory from Accumulator with Borrow
	OPSTART	229
	OPCALL	DIRECT,SBC,2,3,2,3
	OPEND	229


CMD65816_INC_DIRECT
	;Increment Memory or Accumulator by One
	OPSTART	230
	OPCALL	DIRECT,INC,2,5,2,5
	OPEND	230


CMD65816_SBC_DIRECTINDIRECTLONG
	;Subtract Memory from Accumulator with Borrow
	OPSTART	231
	OPCALL	DIRECTINDIRECTLONG,SBC,2,6,2,6
	OPEND	231


CMD65816_INX_IMPLIED
	;Increment Index X by One
	OPSTART	232
	CheckEX	inx_implied

	add.w	#1,d6
	SCCR	%10000010,0,0

	RETURNOP	1,2

.bs_inx_implied

	add.b	#1,d6
	SCCR	%10000010,0,0

	RETURNOP	1,2
	OPEND	232


CMD65816_SBC_IMMEDIATE
	;Subtract Memory from Accumulator with Borrow
	OPSTART	233
	CheckEM	sbc_immediate

	GETARGW	0
	move.w	a5,d1
	and.w	#$0001,d1
	eor.w	#$0001,d1
	add.w	d1,d0
	sub.w	d0,d7
	SCCR	%11000011,0,0

	RETURNOP	3,2

.bs_sbc_immediate

	GETARGB	0
	move.w	a5,d1
	and.w	#$0001,d1
	eor.w	#$0001,d1
	add.b	d1,d0
	sub.b	d0,d7
	SCCR	%11000011,0,0

	RETURNOP	2,2
	OPEND	233


CMD65816_NOP_IMPLIED
	;No Operation
	OPSTART	234
	RETURNOP	1,2
	OPEND	234


CMD65816_XBA_IMPLIED
	;Exchange AH and AL
	OPSTART	235
	ror.w	#8,d7
	tst.b	d7
	SCCR	%10000010,0,0

	RETURNOP	1,3
	OPEND	235


CMD65816_CPX_ABSOLUTE
	;Compare Memory and Index X
	OPSTART	236
	CheckEM	cpx_absolute

	GETARGW	0

	move.l	a4,d1
	lsr.l	#8,d1
	move.w	d0,d1
	move.l	d1,d0

	GETARGW	0
	cmp.w	d0,d6
	SCCR	%10000011,0,0

	RETURNOP	3,4

.bs_cpx_absolute

	GETARGW	0

	move.l	a4,d1
	lsr.l	#8,d1
	move.w	d0,d1
	move.l	d1,d0

	GETARGB	0
	cmp.b	d0,d6
	SCCR	%10000011,0,0

	RETURNOP	3,4
	OPEND	236


CMD65816_SBC_ABSOLUTE
	;Subtract Memory from Accumulator with Borrow
	OPSTART	237
	OPCALL	ABSOLUTE,SBC,3,4,3,4
	OPEND	237


CMD65816_INC_ABSOLUTE
	;Increment Memory or Accumulator by One
	OPSTART	238
	OPCALL	ABSOLUTE,INC,3,6,3,6
	OPEND	238


CMD65816_SBC_ABSOLUTELONG
	;Subtract Memory from Accumulator with Borrow
	OPSTART	239
	OPCALL	ABSOLUTELONG,SBC,4,5,4,5
	OPEND	239


CMD65816_BEQ_PCRELATIVE
	;Branch if Equal (Pz = 1)
	OPSTART	240
	move.l	a5,d0
	and.w	#(CPUPF_Z),d0
	bne	.taken_beq_pcrelative

	RETURNOP	2,2

.taken_beq_pcrelative

	GETARGB	0
	ext.w	d0
	move.l	a4,d1
	add.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	2,3
	OPEND	240


CMD65816_SBC_DIRECTINDIRECTINDEX
	;Subtract Memory from Accumulator with Borrow
	OPSTART	241
	OPCALL	DIRECTINDIRECTINDEX,SBC,2,5,2,5
	OPEND	241


CMD65816_SBC_DIRECTINDIRECT
	;Subtract Memory from Accumulator with Borrow
	OPSTART	242
	OPCALL	DIRECTINDIRECT,SBC,2,5,2,5
	OPEND	242


CMD65816_SBC_STACKRELATIVEINDIRECTINDEX
	;Subtract Memory from Accumulator with Borrow
	OPSTART	243
	OPCALL	STACKRELATIVEINDIRECTINDEX,SBC,2,7,2,7
	OPEND	243


CMD65816_PEA_STACK
	;Push Effective Absolute Address on Stack (or Push Immediate Data on Stack)
	OPSTART	244
	GETARGW
	PUSHW	d0

	RETURNOP	3,5
	OPEND	244


CMD65816_SBC_DIRECTINDEX_X
	;Subtract Memory from Accumulator with Borrow
	OPSTART	245
	OPCALL	DIRECTINDEX_X,SBC,2,4,2,4
	OPEND	245


CMD65816_INC_DIRECTINDEX_X
	;Increment Memory or Accumulator by One
	OPSTART	246
	OPCALL	DIRECTINDEX_X,INC,2,6,2,6
	OPEND	246


CMD65816_SBC_DIRECTINDIRECTINDEXLONG
	;Subtract Memory from Accumulator with Borrow
	OPSTART	247
	OPCALL	DIRECTINDIRECTINDEXLONG,SBC,2,6,2,6
	OPEND	247


CMD65816_SED_IMPLIED
	;Set Decimal Mode
	OPSTART	248
	move.l	a5,d0
	or.w	#CPUPF_D,d0
	move.l	d0,a5

	RETURNOP	1,2
	OPEND	248


CMD65816_SBC_ABSOLUTEINDEX_Y
	;Subtract Memory from Accumulator with Borrow
	OPSTART	249
	OPCALL	ABSOLUTEINDEX_Y,SBC,3,4,3,4
	OPEND	249


CMD65816_PLX_STACK
	;Pull Index X from Stack
	OPSTART	250
	ChecKEX	plx_stack

	PULLW
	move.w	d0,d6
	SCCR	%10000010,0,0

	RETURNOP	1,4

.bs_plx_stack

	PULLB
	move.b	d0,d6
	SCCR	%10000010,0,0

	RETURNOP	1,4
	OPEND	250


CMD65816_XCE_IMPLIED
	;Exchange Carry and Emulation Bits
	OPSTART	251
	move.l	a5,d0
	move.l	d0,d1
	and.w	#(CPUPF_E|CPUPF_C),d0
	and.w	#~(CPUPF_E|CPUPF_C),d1
	ror.w	#8,d0
	or.w	d0,d1
	move.l	d1,a5

	CheckE	xce_implied

	RETURNOP	1,2

.em_xce_implied

	and.l	#$00ff00ff,d6
	move.l	a5,d0
	swap	d0
	ror.w	#8,d0
	move.b	#$01,d0
	rol.w	#8,d0
	swap	d0
	or.b	#(CPUPF_M|CPUPF_X),d0
	move.l	d0,a5

	RETURNOP	1,2
	OPEND	251


CMD65816_JSR_ABSOLUTEINDEXEDINDIRECT
	;Jump to New Location Saving Return Address
	OPSTART	252
	move.l	a4,d1
	add.l	#3,d1
	PUSHW	d1

	GETARGW
	move.l	a4,d1
	and.l	#$00ff0000,d1
	move.w	d0,d1
	add.w	d6,d1
	move.l	d1,d0

	move.l	a4,d1
	move.w	d0,d1
	move.l	d1,a4

	CACHET

	RETURNOP	3,6
	OPEND	252


CMD65816_SBC_ABSOLUTEINDEX_X
	;Subtract Memory from Accumulator with Borrow
	OPSTART	253
	OPCALL	ABSOLUTEINDEX_X,SBC,3,4,3,4
	OPEND	253


CMD65816_INC_ABSOLUTEINDEX_X
	;Increment Memory or Accumulator by One
	OPSTART	254
	OPCALL	ABSOLUTEINDEX_X,INC,3,7,3,7
	OPEND	254


CMD65816_SBC_ABSOLUTEINDEXLONG
	;Subtract Memory from Accumulator with Borrow
	OPSTART	255
	OPCALL	ABSOLUTEINDEXLONG,SBC,4,5,4,5
	OPEND	255


	section	data,data

CCR_Table
	dc.b	%00000000
	dc.b	%00000001
	dc.b	%01000000
	dc.b	%01000001
	dc.b	%00000010
	dc.b	%00000011
	dc.b	%01000010
	dc.b	%01000011
	dc.b	%10000000
	dc.b	%10000001
	dc.b	%11000000
	dc.b	%11000001
	dc.b	%10000010
	dc.b	%10000011
	dc.b	%11000010
	dc.b	%11000011

	section	bss,bss

prg_Opcode		ds.l	1
